[dpdk-dev] [PATCH] net/netvsc: fix txq leak in error path

Long Li longli at microsoft.com
Thu Oct 1 00:27:29 CEST 2020


>Subject: [dpdk-dev] [PATCH] net/netvsc: fix txq leak in error path
>
>From: Yunjian Wang <wangyunjian at huawei.com>
>
>In hn_dev_tx_queue_setup() allocated memory for txq, we should free it
>when error happens, otherwise it will lead to memory leak.
>
>Fixes: cc0251813277 ("net/netvsc: split send buffers from Tx descriptors")
>Cc: stable at dpdk.org
>
>Signed-off-by: Yunjian Wang <wangyunjian at huawei.com>
>---
> drivers/net/netvsc/hn_rxtx.c | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
>index 65f1abae5..8c94e7ee3 100644
>--- a/drivers/net/netvsc/hn_rxtx.c
>+++ b/drivers/net/netvsc/hn_rxtx.c
>@@ -273,6 +273,7 @@ hn_dev_tx_queue_setup(struct rte_eth_dev *dev,
> 			     " (tx_free_thresh=%u port=%u queue=%u)\n",
> 			     nb_desc - 3,
> 			     tx_free_thresh, dev->data->port_id, queue_idx);
>+		rte_free(txq);
> 		return -EINVAL;
> 	}
>
>--
>2.23.0

How about checking for tx_free_thresh at the beginning of the function, before calling txq = rte_zmalloc_socket()? 

This way, you don't' need to call rte_free() on error.

Long


More information about the dev mailing list