[dpdk-stable] [PATCH v2] examples/vhost: fix memory leak on forwarding packets

Xia, Chenbo chenbo.xia at intel.com
Tue Aug 31 07:50:24 CEST 2021


Hi Wenwu,

> -----Original Message-----
> From: Ma, WenwuX <wenwux.ma at intel.com>
> Sent: Friday, August 27, 2021 10:01 PM
> To: dev at dpdk.org
> Cc: maxime.coquelin at redhat.com; Xia, Chenbo <chenbo.xia at intel.com>; Jiang,
> Cheng1 <cheng1.jiang at intel.com>; Hu, Jiayu <jiayu.hu at intel.com>; Ma, WenwuX
> <wenwux.ma at intel.com>; stable at dpdk.org
> Subject: [PATCH v2] examples/vhost: fix memory leak on forwarding packets
> 
> In function virtio_tx_local(), when the device receiving the packet
> is the same as the device to which the packet is forwarded,
> or the device is removed, we return but not free the packet,
> it will cause a memory leak.
> 
> Fixes: 4796ad63ba1f ("examples/vhost: import userspace vhost application")
> Cc: stable at dpdk.org
> 
> v2:
> - Delete '.' in the title.
> 
> Signed-off-by: Wenwu Ma <wenwux.ma at intel.com>

The version description should be after signed-off-by tag like:

Signed-off-by: Wenwu Ma <wenwux.ma at intel.com>
---

v2:XXX

---
examples/vhost/main.c | 2 ++

Please fix this to save Maxime's effort when applying.
And you missed the Acked-by/Reviewed-by tag of Jiayu/Cheng/Mine.

Thanks,
Chenbo

> ---
>  examples/vhost/main.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/examples/vhost/main.c b/examples/vhost/main.c
> index bc3d71c898..07fd90ec64 100644
> --- a/examples/vhost/main.c
> +++ b/examples/vhost/main.c
> @@ -965,6 +965,7 @@ virtio_tx_local(struct vhost_dev *vdev, struct rte_mbuf *m)
>  		return -1;
> 
>  	if (vdev->vid == dst_vdev->vid) {
> +		rte_pktmbuf_free(m);
>  		RTE_LOG_DP(DEBUG, VHOST_DATA,
>  			"(%d) TX: src and dst MAC is same. Dropping packet.\n",
>  			vdev->vid);
> @@ -975,6 +976,7 @@ virtio_tx_local(struct vhost_dev *vdev, struct rte_mbuf *m)
>  		"(%d) TX: MAC address is local\n", dst_vdev->vid);
> 
>  	if (unlikely(dst_vdev->remove)) {
> +		rte_pktmbuf_free(m);
>  		RTE_LOG_DP(DEBUG, VHOST_DATA,
>  			"(%d) device is marked for removal\n", dst_vdev->vid);
>  		return 0;
> --
> 2.25.1



More information about the stable mailing list