From nobody Mon Feb 9 10:28:45 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1641607045; cv=none; d=zohomail.com; s=zohoarc; b=lmI1VzcEvsOaNDIqTVFNNOxpq0g0nYUuRaHtElCEpm3wgx+ulM/o8mB58R5jpUUfj62zXBIiBPmgORcyAhSbNRSHhku+X59R06f6ZPShZz+d9X8/LVnTHliKzBOoIS+jch3TgCycJYog9XHct5VD+MjlErB/WCrtVc2idauA4Z0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641607045; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sZKl68SrJVJX9J/g8uBNG773VeE63EY7yyNvoTLPOxc=; b=HOHfKX/ekJ5CdNkri7pD4FDHKY7LRP9nPn5gQ9gzI/g2pOSNf75a2pJ/l3CBoxkWmSLyXI/Av4SNkttWwrTtK7IwNYv9vM8YWpLS+/3lfdCDDjcCKSfZzyCjue9GK5DIA8cIo2UgUoGx4HaQ4xi2NvAwIV6x3M9c3NcdTk354BQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1641607045118465.33848902649993; Fri, 7 Jan 2022 17:57:25 -0800 (PST) Received: from localhost ([::1]:56158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n60yx-0007RK-VC for importer@patchew.org; Fri, 07 Jan 2022 20:57:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n60Bl-0006ec-Ai for qemu-devel@nongnu.org; Fri, 07 Jan 2022 20:06:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51440) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n60Bj-0002uv-Sw for qemu-devel@nongnu.org; Fri, 07 Jan 2022 20:06:33 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-516--JDPA-g1ME6V9XRtP0bVRw-1; Fri, 07 Jan 2022 20:06:30 -0500 Received: by mail-wm1-f70.google.com with SMTP id n3-20020a05600c3b8300b00345c3fc40b0so5619305wms.3 for ; Fri, 07 Jan 2022 17:06:30 -0800 (PST) Received: from redhat.com ([147.161.13.99]) by smtp.gmail.com with ESMTPSA id b10sm74399wmj.42.2022.01.07.17.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jan 2022 17:06:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641603991; 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=XpF4LdFbyJPXPSuMyFuiVnLP1d6NDPWobcJ47xCOQ/Y5CQ+wYL2/BMR9VIrBOwZwBcP9Ha RxrP47KQ22siIP+KwdvbQ6e04W+4XPsV95PRsnwW0mubrZPjhWcm1/JL4IgeargdvGw2Jp Rj1dnt596ZafwdMwSK4SJtDHve5cA2k= X-MC-Unique: -JDPA-g1ME6V9XRtP0bVRw-1 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=gi3yCjJAAgk/LOBTXoEbbh67nuLwoA/XtMoANvVrznkNujCSlGUc4w5TKGdBmfovzi mCwLnBbo7InB17a7qSJ44O8IUUf0A1Xp7sBxNuxa/hczp4PFayg6pL6ZpMRQvvx886p8 cfstes5Vs5WX5cppFc74X1QUzuJErEM5q9zwL1XaD1Wjy6iycnsUcQLnSiEnzFN2Hqqd tQUsusj7v8EHUIzGJKXQ8mYJsKb9ZTulhjhwi0Sm7zsbPlC39bcaM45Z4N7/7RkzrttO q2WnmHVYBY+EHQzQ+kkDs7t81qGVFfBk0LFTlXSdxWB0wFZip7OtSBanKGBTGae7KdQ9 CUzg== X-Gm-Message-State: AOAM533M0cNFw3jP/VVMNdXRTNZ2xG0RXvo+BQXAxbxMqriYV28Q4YoG 8ea/JFgtqhc4pdU8RrwELllq3a9+AYBOEmF+acMCEYxOYd5SIVg8FF2aRFIOs2IqJMY+EzDmkGm uZDDOKga8rcNJq8KahbeC4iElhAzIh1BYDB82TGOgScrX8+JKgwAxo3amZbij X-Received: by 2002:a05:6000:24b:: with SMTP id m11mr11149219wrz.122.1641603988910; Fri, 07 Jan 2022 17:06:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzy4bEN0GjhnFWAgKXrwL+MNoBVoD/YQXdyhjY8biuSauI0FXZQgLryuVb7B/RD6FcGnUpn7Q== X-Received: by 2002:a05:6000:24b:: with SMTP id m11mr11149206wrz.122.1641603988656; Fri, 07 Jan 2022 17:06:28 -0800 (PST) Date: Fri, 7 Jan 2022 20:06:25 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Subject: [PULL v3 52/55] virtio/vhost-vsock: don't double close vhostfd, remove redundant cleanup Message-ID: <20220108003423.15830-53-mst@redhat.com> References: <20220108003423.15830-1-mst@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220108003423.15830-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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1641607046012100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 *de= v, Error **errp) ret =3D 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; } =20 @@ -183,15 +187,10 @@ static void vhost_vsock_device_realize(DeviceState *d= ev, Error **errp) return; =20 err_vhost_dev: - vhost_dev_cleanup(&vvc->vhost_dev); /* vhost_dev_cleanup() closes the vhostfd passed to vhost_dev_init() */ - vhostfd =3D -1; + vhost_dev_cleanup(&vvc->vhost_dev); err_virtio: vhost_vsock_common_unrealize(vdev); - if (vhostfd >=3D 0) { - close(vhostfd); - } - return; } =20 static void vhost_vsock_device_unrealize(DeviceState *dev) --=20 MST