From nobody Wed May 8 21:14:20 2024 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=1659365469; cv=none; d=zohomail.com; s=zohoarc; b=ljJ3bCccl1gNLMh9qFiUpdnT+ahWFXOfd1WphamLab4KzAqMTCJEYWzKSbJ2lX6DYoI7SYrQTRzz/fNpnQrDOZ1KshPr+K8/airODC0NSae0SHcHz8t/ztdailUFJPNNVKfFJPWKlEwn4Fb/xuDblrfIjgXmP4kDIYYkOPFl84M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659365469; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=TZ83/2iKBYgUumgQVCnyKZLgWLPFYMPqVj7+h/Iq+ts=; b=R+BgYxWzA236Vq8oWZFsHC78c0Q5TVZpo6ggYXN2cTt0IeNqcZVz6IuthuKfGQqc4lj5qfE/KU841z8DYcM7+UHnv7JfEJxrikT1z1gBr4Xs3DOPTtt1BbmMQwQs1m8YQUuqIN6p5Wdpf/7hkuHegQWBwH5hK3gMkmEnEWzCyS4= 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 1659365469845112.83496576429764; Mon, 1 Aug 2022 07:51:09 -0700 (PDT) Received: from localhost ([::1]:49428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIWl8-0000BD-BA for importer@patchew.org; Mon, 01 Aug 2022 10:51:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIWhY-0007h1-E7 for qemu-devel@nongnu.org; Mon, 01 Aug 2022 10:47:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:33949) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIWhV-0006m8-Oz for qemu-devel@nongnu.org; Mon, 01 Aug 2022 10:47:23 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-299-2AAiL7JIOMW1x0aVsBD1rg-1; Mon, 01 Aug 2022 10:47:17 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1E9698058F0; Mon, 1 Aug 2022 14:47:17 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4374492CA2; Mon, 1 Aug 2022 14:47:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659365240; 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: content-transfer-encoding:content-transfer-encoding; bh=TZ83/2iKBYgUumgQVCnyKZLgWLPFYMPqVj7+h/Iq+ts=; b=KDZVT3Y1iCGhKMmL7sZnUYtkfsgATqcepM9P+lXL7UebJAthNgUhlOMGCUbFLQ7X/LzL5r QvnewOoLy1qKNE2kSTWWyZ74ZGVG+g1zpSbJUnpF/9sC6KmR5ue3o3rcwrmUhIm/fB9lTJ MCi0CjZbN59Jkab0Cq15pv7xcwSrKRY= X-MC-Unique: 2AAiL7JIOMW1x0aVsBD1rg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Jason Wang , "Michael S . Tsirkin" , Peter Maydell , qemu-trivial@nongnu.org, Laurent Vivier Subject: [PATCH] vdpa: Fix file descriptor leak on get features error Date: Mon, 1 Aug 2022 16:47:14 +0200 Message-Id: <20220801144714.181644-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 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.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1659365471065100001 File descriptor vdpa_device_fd is not free in the case of returning error from vhost_vdpa_get_features. Fixing it by making all errors go to the same error path. Resolves: Coverity CID 1490785 Fixes: 8170ab3f43 ("vdpa: Extract get features part from vhost_vdpa_get_max= _queue_pairs") Signed-off-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 6abad276a6..303447a68e 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -566,7 +566,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, g_autofree NetClientState **ncs =3D NULL; g_autoptr(VhostIOVATree) iova_tree =3D NULL; NetClientState *nc; - int queue_pairs, r, i, has_cvq =3D 0; + int queue_pairs, r, i =3D 0, has_cvq =3D 0; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); opts =3D &netdev->u.vhost_vdpa; @@ -582,7 +582,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, =20 r =3D vhost_vdpa_get_features(vdpa_device_fd, &features, errp); if (unlikely(r < 0)) { - return r; + goto err; } =20 queue_pairs =3D vhost_vdpa_get_max_queue_pairs(vdpa_device_fd, feature= s, --=20 2.31.1