[dpdk-dev] [PATCH] ethdev: fix memory leaks in remove rxtx callbacks

Ananyev, Konstantin konstantin.ananyev at intel.com
Thu Dec 14 10:16:35 CET 2017



> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Abhinandan Gujjar
> Sent: Thursday, December 14, 2017 3:32 AM
> To: thomas at monjalon.net
> Cc: dev at dpdk.org; Gujjar, Abhinandan S <abhinandan.gujjar at intel.com>
> Subject: [dpdk-dev] [PATCH] ethdev: fix memory leaks in remove rxtx callbacks
> 
> The patch frees memory allocated by add rxtx callbacks
> 
> Signed-off-by: Abhinandan Gujjar <abhinandan.gujjar at intel.com>
> ---
>  lib/librte_ether/rte_ethdev.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
> index 318af28..2ab6e05 100644
> --- a/lib/librte_ether/rte_ethdev.c
> +++ b/lib/librte_ether/rte_ethdev.c
> @@ -3229,6 +3229,7 @@ int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
>  		if (cb == user_cb) {
>  			/* Remove the user cb from the callback list. */
>  			*prev_cb = cb->next;
> +			rte_free(cb);

It is not that straightforward unfortunately -
that function can be called while RX/TX is active for the same queue.
That's why it is a responsibility of the caller to determine when it is safe
to free associated resources. 
I submitted and RFC to fix that issue in a safe way:
http://dpdk.org/dev/patchwork/patch/31867/
Konstantin

>  			ret = 0;
>  			break;
>  		}
> @@ -3263,6 +3264,7 @@ int rte_eth_set_queue_rate_limit(uint16_t port_id, uint16_t queue_idx,
>  		if (cb == user_cb) {
>  			/* Remove the user cb from the callback list. */
>  			*prev_cb = cb->next;
> +			rte_free(cb);
>  			ret = 0;
>  			break;
>  		}
> --
> 1.9.1



More information about the dev mailing list