From: Stephen Hemminger Date: Mon, 6 Jan 2020 19:18:37 +0000 (-0800) Subject: net/virtio-user: check file descriptor before closing X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b56c12acf20585ad46faf9455b4b9aeb30450ef0;p=dpdk.git net/virtio-user: check file descriptor before closing Valgrind complains that virtio_user is calling close(-1). Fix this by adding check in virtio that is similar to existing code. Fixes: 37a7eb2ae816 ("net/virtio-user: add device emulation layer") Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger Reviewed-by: Tiwei Bie --- diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index ea016e85d8..ffbaa75b7e 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -537,7 +537,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);