Skip to content

Commit

Permalink
vdpa: Fix file descriptor leak on get features error
Browse files Browse the repository at this point in the history
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: 8170ab3 ("vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs")

Signed-off-by: Eugenio Pérez <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Reviewed-by: Michael S. Tsirkin <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Laurent Vivier <[email protected]>
  • Loading branch information
eugpermar authored and vivier committed Aug 4, 2022
1 parent 9567fc1 commit aed5da4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/vhost-vdpa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down

0 comments on commit aed5da4

Please sign in to comment.