[PATCH] net/cpfl: fix memory leak

Zhang, Qi Z qi.z.zhang at intel.com
Wed Oct 18 04:05:34 CEST 2023



> -----Original Message-----
> From: beilei.xing at intel.com <beilei.xing at intel.com>
> Sent: Tuesday, October 17, 2023 7:07 PM
> To: Wu, Jingjing <jingjing.wu at intel.com>
> Cc: dev at dpdk.org; Xing, Beilei <beilei.xing at intel.com>; stable at dpdk.org
> Subject: [PATCH] net/cpfl: fix memory leak
> 
> From: Beilei Xing <beilei.xing at intel.com>
> 
> Fix resource leak reported in coverity scan.
> 
> Coverity issue: 403265
> Fixes: 2d823ecd671c ("net/cpfl: support device initialization")
> Fixes: 989465ac51ea ("net/cpfl: support probe again")
> Cc: stable at dpdk.org
> 
> Signed-off-by: Beilei Xing <beilei.xing at intel.com>
> ---
>  drivers/net/cpfl/cpfl_ethdev.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
> index 890a027a1d..0093deab5a 100644
> --- a/drivers/net/cpfl/cpfl_ethdev.c
> +++ b/drivers/net/cpfl/cpfl_ethdev.c
> @@ -1626,7 +1626,8 @@ cpfl_parse_devargs(struct rte_pci_device *pci_dev,
> struct cpfl_adapter_ext *adap
> 
>  	if (rte_kvargs_count(kvlist, CPFL_VPORT) > 1) {
>  		PMD_INIT_LOG(ERR, "devarg vport is duplicated.");
> -		return -EINVAL;
> +		ret = -EINVAL;
> +		goto fail;
>  	}
> 
>  	ret = rte_kvargs_process(kvlist, CPFL_REPRESENTOR, &parse_repr,
> cpfl_args); @@ -1635,7 +1636,7 @@ cpfl_parse_devargs(struct
> rte_pci_device *pci_dev, struct cpfl_adapter_ext *adap
>  		goto fail;
> 
>  	if (!first)
> -		return 0;
> +		goto fail;

goto fail in a success case cause confusion, maybe we can rename "fail" as "finish", or adding a another label right before "fail"?
> 
>  	ret = rte_kvargs_process(kvlist, CPFL_VPORT, &parse_vport,
>  				 cpfl_args);
> --
> 2.34.1



More information about the dev mailing list