Skip to content

Commit

Permalink
net/virtio-user: check file descriptor before closing
Browse files Browse the repository at this point in the history
[ upstream commit b56c12a ]

Valgrind complains that virtio_user is calling close(-1).
Fix this by adding check in virtio that is similar to existing code.

Fixes: 37a7eb2 ("net/virtio-user: add device emulation layer")

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Tiwei Bie <tiwei.bie@intel.com>
  • Loading branch information
shemminger authored and kevintraynor committed Feb 7, 2020
1 parent 59e1f98 commit a3f5b5b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/virtio/virtio_user/virtio_user_dev.c
Expand Up @@ -524,7 +524,8 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev)
close(dev->kickfds[i]);
}

close(dev->vhostfd);
if (dev->vhostfd >= 0)
close(dev->vhostfd);

if (dev->is_server && dev->listenfd >= 0) {
close(dev->listenfd);
Expand Down

0 comments on commit a3f5b5b

Please sign in to comment.