[dpdk-dev] [PATCH] pipeline: fix deallocate null pointer

Dumitrescu, Cristian cristian.dumitrescu at intel.com
Thu Apr 22 10:36:21 CEST 2021



> -----Original Message-----
> From: Min Hu (Connor) <humin29 at huawei.com>
> Sent: Thursday, April 22, 2021 7:39 AM
> To: dev at dpdk.org
> Cc: Yigit, Ferruh <ferruh.yigit at intel.com>; Dumitrescu, Cristian
> <cristian.dumitrescu at intel.com>
> Subject: [PATCH] pipeline: fix deallocate null pointer
> 
> From: HongBo Zheng <zhenghongbo3 at huawei.com>
> 
> Fix deallocate null pointer in instruction_config, while
> pointer 'data' or 'instr' may be null.
> 
> Fixes: a1711f948dbf ("pipeline: add SWX Rx and extract instructions")
> Cc: stable at dpdk.org
> 
> Signed-off-by: HongBo Zheng <zhenghongbo3 at huawei.com>
> Signed-off-by: Min Hu (Connor) <humin29 at huawei.com>
> ---
>  lib/librte_pipeline/rte_swx_pipeline.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_pipeline/rte_swx_pipeline.c
> b/lib/librte_pipeline/rte_swx_pipeline.c
> index 4455d91..6084635 100644
> --- a/lib/librte_pipeline/rte_swx_pipeline.c
> +++ b/lib/librte_pipeline/rte_swx_pipeline.c
> @@ -8015,8 +8015,10 @@ instruction_config(struct rte_swx_pipeline *p,
>  	return 0;
> 
>  error:
> -	free(data);
> -	free(instr);
> +	if (data)
> +		free(data);
> +	if (instr)
> +		free(instr);
>  	return err;
>  }
> 
> --
> 2.7.4

Hi,

NACK.

Thanks for the patch, but the tests for data and instr being non-NULL before calling free are not required, because:
1. Both data and instr are initialized to NULL.
2. free(NULL) is supported.

Regards,
Cristian


More information about the dev mailing list