vhost: fix slave request fd leak

Message ID 20190905110125.19946-1-tiwei.bie@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers
Series vhost: fix slave request fd leak |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-dpdk_compile_ovs success Compile Testing PASS
ci/iol-dpdk_compile success Compile Testing PASS
ci/iol-dpdk_compile_spdk success Compile Testing PASS
ci/intel-Performance success Performance Testing PASS
ci/mellanox-Performance success Performance Testing PASS

Commit Message

Tiwei Bie Sept. 5, 2019, 11:01 a.m. UTC
  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@dpdk.org

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

Comments

Maxime Coquelin Sept. 9, 2019, 10:13 a.m. UTC | #1
On 9/5/19 1:01 PM, Tiwei Bie wrote:
> 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@dpdk.org
> 
> Signed-off-by: Tiwei Bie <tiwei.bie@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;
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  
Maxime Coquelin Sept. 18, 2019, 1:09 p.m. UTC | #2
On 9/5/19 1:01 PM, Tiwei Bie wrote:
> 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@dpdk.org
> 
> Signed-off-by: Tiwei Bie <tiwei.bie@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;
> 

Applied to dpdk-next-virtio/master.

Thanks,
Maxime
  

Patch

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;