[dpdk-dev] [PATCH] vhost: fix slave request fd leak

Tiwei Bie tiwei.bie at intel.com
Thu Sep 5 13:01:25 CEST 2019


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

Fixes: 275c3f944730 ("vhost: support slave requests channel")
Cc: stable at dpdk.org

Signed-off-by: Tiwei Bie <tiwei.bie at intel.com>
---
 lib/librte_vhost/vhost_user.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 0b72648a5..f46843610 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -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;
-- 
2.17.1



More information about the dev mailing list