All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, "Laurent Vivier" <laurent@vivier.eu>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>
Subject: [PULL 2/5] vdpa: Fix file descriptor leak on get features error
Date: Thu,  4 Aug 2022 21:22:13 +0200	[thread overview]
Message-ID: <20220804192216.1958922-3-laurent@vivier.eu> (raw)
In-Reply-To: <20220804192216.1958922-1-laurent@vivier.eu>

From: Eugenio Pérez <eperezma@redhat.com>

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érez <eperezma@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20220802112447.249436-2-eperezma@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 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 6abad276a61a..303447a68e8b 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -566,7 +566,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
     g_autofree NetClientState **ncs = NULL;
     g_autoptr(VhostIOVATree) iova_tree = NULL;
     NetClientState *nc;
-    int queue_pairs, r, i, has_cvq = 0;
+    int queue_pairs, r, i = 0, has_cvq = 0;
 
     assert(netdev->type == NET_CLIENT_DRIVER_VHOST_VDPA);
     opts = &netdev->u.vhost_vdpa;
@@ -582,7 +582,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name,
 
     r = vhost_vdpa_get_features(vdpa_device_fd, &features, errp);
     if (unlikely(r < 0)) {
-        return r;
+        goto err;
     }
 
     queue_pairs = vhost_vdpa_get_max_queue_pairs(vdpa_device_fd, features,
-- 
2.37.1



  parent reply	other threads:[~2022-08-04 19:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04 19:22 [PULL 0/5] Trivial branch for 7.1 patches Laurent Vivier
2022-08-04 19:22 ` [PULL 1/5] README.rst: fix link formatting Laurent Vivier
2022-08-04 19:22 ` Laurent Vivier [this message]
2022-08-04 19:22 ` [PULL 3/5] docs/about/removed-features: Move the -soundhw into the right section Laurent Vivier
2022-08-04 19:22 ` [PULL 4/5] ppc: Remove redundant macro MSR_BOOK3S_MASK Laurent Vivier
2022-08-04 19:22 ` [PULL 5/5] include/qemu/host-utils.h: Simplify the compiler check in mulu128() Laurent Vivier
2022-08-05  2:01 ` [PULL 0/5] Trivial branch for 7.1 patches Richard Henderson
2022-08-05  5:52 ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220804192216.1958922-3-laurent@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=eperezma@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.