Skip to content

Commit

Permalink
vhost: fix fd leak in kick setup
Browse files Browse the repository at this point in the history
[ upstream commit bc900f8 ]

This patch fixes a file descriptor leak which happens
in the error path of vhost_user_set_vring_kick().

Fixes: 4796ad6 ("examples/vhost: import userspace vhost application")

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: Xueming Li <xuemingl@nvidia.com>
  • Loading branch information
mcoquelin authored and bluca committed Nov 16, 2020
1 parent 98e192a commit 4089c1d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/librte_vhost/vhost_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -1844,8 +1844,12 @@ vhost_user_set_vring_kick(struct virtio_net **pdev, struct VhostUserMsg *msg,

/* Interpret ring addresses only when ring is started. */
dev = translate_ring_addresses(dev, file.index);
if (!dev)
if (!dev) {
if (file.fd != VIRTIO_INVALID_EVENTFD)
close(file.fd);

return RTE_VHOST_MSG_RESULT_ERR;
}

*pdev = dev;

Expand Down

0 comments on commit 4089c1d

Please sign in to comment.