Skip to contentSkip to conversation

net/virtio_user: do not close invalid file descriptor

PATCH Applied Stephen Hemminger 3 participants 3 messages Jan 6, 2020 – Jan 9, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/virtio_user: do not close invalid file descriptor

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")
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/virtio/virtio_user/virtio_user_dev.c +2 -1
index ea016e85d8af..ffbaa75b7e83 100644
@@ -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);
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Stephen Hemminger

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")
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
#2 lore raw
Quoted 12 lines · Tiwei Bie
Quoted 10 lines · Stephen Hemminger

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")
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 2 lines

Applied to dpdk-next-virtio/master.

Thanks,
Maxime