[dpdk-dev] [PATCH 1/6] net/mlx5: fix hairpin Tx queue creation error flow

Raslan Darawsheh rasland at mellanox.com
Sun May 31 13:26:32 CEST 2020


Hi,

> -----Original Message-----
> From: dev <dev-bounces at dpdk.org> On Behalf Of Michael Baum
> Sent: Wednesday, May 27, 2020 11:38 AM
> To: dev at dpdk.org
> Cc: Matan Azrad <matan at mellanox.com>; Slava Ovsiienko
> <viacheslavo at mellanox.com>; stable at dpdk.org
> Subject: [dpdk-dev] [PATCH 1/6] net/mlx5: fix hairpin Tx queue creation
> error flow
> 
> The mlx5_txq_obj_hairpin_new function defines a pointer named tmpl and
> allocates memory for it using the rte_zmalloc_socket function.
> Later, this function allocates memory to a variable inside tmpl using
> the mlx5_devx_cmd_create_sq function.
> 
> In both cases, if the allocation fails, the code jumps to the error
> label and frees allocated resources. However, in the first jump there
> are still no resources to free and the jump only for the line return
> NULL is unnecessary. Even worse, when it jumps to error label with
> invalid tmpl it actually does dereference to a null pointer.
> In contrast, the second jump needs to free the tmpl variable but the
> function instead of freeing, tries to free the variable that it just
> failed to allocate, and another variable that has never been allocated.
> In addition, for another error, the function returns NULL without
> freeing the tmpl variable before, causing a memory leak.
> 
> Delete the error label and replace each jump with local return NULL and
> free tmpl variable if needed.
> 
> Fixes: ae18a1ae9692 ("net/mlx5: support Tx hairpin queues")
> Cc: stable at dpdk.org
> 
> Signed-off-by: Michael Baum <michaelba at mellanox.com>
> Acked-by: Matan Azrad <matan at mellanox.com>
> ---
>  drivers/net/mlx5/mlx5_txq.c | 15 ++++-----------
>  1 file changed, 4 insertions(+), 11 deletions(-)
> 

Series applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh


More information about the dev mailing list