From patchwork Thu Jan 6 13:18:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1576133 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Hvi0E7Ws; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JV7bn3Jbfz9sCD for ; Fri, 7 Jan 2022 01:12:53 +1100 (AEDT) Received: from localhost ([::1]:50258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5TVb-0003m6-A7 for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2022 09:12:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SfO-0006aU-JT for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46938) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5SfM-00017Z-Vl for qemu-devel@nongnu.org; Thu, 06 Jan 2022 08:18:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641475132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sZKl68SrJVJX9J/g8uBNG773VeE63EY7yyNvoTLPOxc=; b=Hvi0E7WsphqjpF9QUnaF6PTqvovzUacwpPtlMK+LSmB1qg5EGuOzdmvgn0BTyXRmJNj+ZP H71lqfOjUuURylh5FeEKOSzDSqUFOvLXx5hLdGCagfwZQckJkraogcGyiGBiivEeIJrPNW CVlHzgG5770z7+hp+wsbOZaZaCqbYlM= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-654-ez0CdN6AOtGu0iODoSafSQ-1; Thu, 06 Jan 2022 08:18:51 -0500 X-MC-Unique: ez0CdN6AOtGu0iODoSafSQ-1 Received: by mail-ed1-f69.google.com with SMTP id s7-20020a056402520700b003f841380832so1943968edd.5 for ; Thu, 06 Jan 2022 05:18:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=sZKl68SrJVJX9J/g8uBNG773VeE63EY7yyNvoTLPOxc=; b=ZSMnMDFb8l82fPZ4OSz6igbSi/NzvqkJ8wZzvyMiAAI32NZoHBiJqJXe7Zte4Wdj3B xRw9w1IObo8jiadgS8R05oSLUpm95dYOWNXdkcqywqKVPUaE9jLq2gTg3raRsA7W04Cv QKRE446IKda6plQ7bidy0PlmxlwooCkhzUqFUXjbyZnLzTm8cAV4vOaTScxilhKqrm5A TQgpdWSrRYWq1qJWIePFWH9DOMisb3s5tV826NkG4ElTudXd11UCInABjLtZBLBo1ldx DfLvUGGOFCJr8lOHMq/eWmZAU+fi99ByO34P0AnRLxKq3LZSbigkjIwDczJT4oO5x8xV HqIQ== X-Gm-Message-State: AOAM530mkQtUofH+x32eZR7qB8+IlAz2SVswSBxDdU/WK0z0pyVJXWR6 upFvYPVF5PdCKwMzFF0jzZdOwAKKd13J0d1INFO/FQlNMuYlCAjkAt2VDkjIDrpS3NI1QHiL70q B6fs2D44nDZ1LBpovkahNJGXsDo2Gz0cRN31VMtZgN4h6/4/BmPcrmoxvhj5t X-Received: by 2002:a05:6402:2793:: with SMTP id b19mr56255000ede.353.1641475130193; Thu, 06 Jan 2022 05:18:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJzcVtpDp46hIDOlR8avCRQF9fh5fJnT8Ik41AdP3NPm9WJosYtOZsntM1M73RJsXUEBeY5YFQ== X-Received: by 2002:a05:6402:2793:: with SMTP id b19mr56254976ede.353.1641475129917; Thu, 06 Jan 2022 05:18:49 -0800 (PST) Received: from redhat.com ([2a03:c5c0:207e:991b:6857:5652:b903:a63b]) by smtp.gmail.com with ESMTPSA id r17sm500302eje.15.2022.01.06.05.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 05:18:49 -0800 (PST) Date: Thu, 6 Jan 2022 08:18:47 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL 52/52] virtio/vhost-vsock: don't double close vhostfd, remove redundant cleanup Message-ID: <20220106131534.423671-53-mst@redhat.com> References: <20220106131534.423671-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220106131534.423671-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mst@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Daniil Tatianin , Stefano Garzarella Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Daniil Tatianin In case of an error during initialization in vhost_dev_init, vhostfd is closed in vhost_dev_cleanup. Remove close from err_virtio as it's both redundant and causes a double close on vhostfd. Signed-off-by: Daniil Tatianin Message-Id: <20211129125204.1108088-1-d-tatianin@yandex-team.ru> Reviewed-by: Stefano Garzarella Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vsock.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c index 478c0c9a87..433d42d897 100644 --- a/hw/virtio/vhost-vsock.c +++ b/hw/virtio/vhost-vsock.c @@ -171,6 +171,10 @@ static void vhost_vsock_device_realize(DeviceState *dev, Error **errp) ret = vhost_dev_init(&vvc->vhost_dev, (void *)(uintptr_t)vhostfd, VHOST_BACKEND_TYPE_KERNEL, 0, errp); if (ret < 0) { + /* + * vhostfd is closed by vhost_dev_cleanup, which is called + * by vhost_dev_init on initialization error. + */ goto err_virtio; } @@ -183,15 +187,10 @@ static void vhost_vsock_device_realize(DeviceState *dev, Error **errp) return; err_vhost_dev: - vhost_dev_cleanup(&vvc->vhost_dev); /* vhost_dev_cleanup() closes the vhostfd passed to vhost_dev_init() */ - vhostfd = -1; + vhost_dev_cleanup(&vvc->vhost_dev); err_virtio: vhost_vsock_common_unrealize(vdev); - if (vhostfd >= 0) { - close(vhostfd); - } - return; } static void vhost_vsock_device_unrealize(DeviceState *dev)