Skip to contentSkip to conversation

vhost: fix slave request fd leak

PATCH Applied Tiwei Bie 2 participants 3 messages Sep 5, 2019 – Sep 18, 2019

lore
Share & tools
lore

Tiwei Bie

author
#0 lore raw

PATCH 1/1 vhost: fix slave request fd leak

We need to close the old slave request fd if any first before taking the new one.

Fixes 275c3f944730 ("vhost: support slave requests channel")
---
 lib/librte_vhost/vhost_user.c | 3 +++
 1 file changed, 3 insertions(+)
lib/librte_vhost/vhost_user.c +3 -0
index 0b72648a5..f46843610 100644
@@ -1564,6 +1564,9 @@ vhost_user_set_req_fd(struct virtio_net **pdev, struct VhostUserMsg *msg,
 		return RTE_VHOST_MSG_RESULT_ERR;
 	}
 
+	if (dev->slave_req_fd >= 0)
+		close(dev->slave_req_fd);
+
 	dev->slave_req_fd = fd;
 
 	return RTE_VHOST_MSG_RESULT_OK;
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Tiwei Bie

We need to close the old slave request fd if any first before taking the new one.

Fixes 275c3f944730 ("vhost: support slave requests channel")
---
 lib/librte_vhost/vhost_user.c | 3 +++
 1 file changed, 3 insertions(+)
lib/librte_vhost/vhost_user.c +0 -0
index 0b72648a5..f46843610 100644

lib/librte_vhost/vhost_user.c vhost_user_set_req_fd(struct virtio_net **pdev, struct VhostUserMsg *msg, · line 1572

Quoted 9 lines
lib/librte_vhost/vhost_user.c +3 -0
@@ -1564,6 +1564,9 @@ vhost_user_set_req_fd(struct virtio_net **pdev, struct VhostUserMsg *msg,
 		return RTE_VHOST_MSG_RESULT_ERR;
 	}
 
+	if (dev->slave_req_fd >= 0)
+		close(dev->slave_req_fd);
+
 	dev->slave_req_fd = fd;
 
 	return RTE_VHOST_MSG_RESULT_OK;

Thanks,
Maxime

#2 lore raw
In reply to Tiwei Bie
Quoted 17 lines · Tiwei Bie

We need to close the old slave request fd if any first before taking the new one.

Fixes 275c3f944730 ("vhost: support slave requests channel")
---
 lib/librte_vhost/vhost_user.c | 3 +++
 1 file changed, 3 insertions(+)
lib/librte_vhost/vhost_user.c +0 -0
index 0b72648a5..f46843610 100644

lib/librte_vhost/vhost_user.c vhost_user_set_req_fd(struct virtio_net **pdev, struct VhostUserMsg *msg, · line 1572

Quoted 9 lines
lib/librte_vhost/vhost_user.c +3 -0
@@ -1564,6 +1564,9 @@ vhost_user_set_req_fd(struct virtio_net **pdev, struct VhostUserMsg *msg,
 		return RTE_VHOST_MSG_RESULT_ERR;
 	}
 
+	if (dev->slave_req_fd >= 0)
+		close(dev->slave_req_fd);
+
 	dev->slave_req_fd = fd;
 
 	return RTE_VHOST_MSG_RESULT_OK;

Applied to dpdk-next-virtio/master.

Thanks,
Maxime