[dpdk-stable] [PATCH] bus/fslmc: fix for resource leak coverity issue

Sachin Saxena sachin.saxena at nxp.com
Thu Oct 3 10:40:02 CEST 2019


Acked-by: Sachin Saxena <sachin.saxena at nxp.com>

regards,
Sachin Saxena

> -----Original Message-----
> From: Agalya Babu RadhaKrishnan <agalyax.babu.radhakrishnan at intel.com>
> Sent: Tuesday, September 10, 2019 1:01 PM
> To: dev at dpdk.org
> Cc: reshma.pattan at intel.com; Hemant Agrawal
> <hemant.agrawal at nxp.com>; Sachin Saxena <sachin.saxena at nxp.com>;
> jananeex.m.parthasarathy at intel.com; Agalya Babu RadhaKrishnan
> <agalyax.babu.radhakrishnan at intel.com>; stable at dpdk.org
> Subject: [PATCH] bus/fslmc: fix for resource leak coverity issue
> Importance: High
> 
> From: Agalya Babu RadhaKrishnan <agalyax.babu.radhakrishnan at intel.com>
> 
> 1 issue caught by 344967
> Leaked_storage: Variable sep going out of scope leaks the storage it points
> to.
> 
> When 'sep' is not null and sep_exist is 0, 'sep' is freed before going out of
> scope of the function irrespective of 'addr' exists or not.
> 
> Coverity Issue: 344967
> Fixes: e67a61614d0b ("bus/fslmc: support device iteration")
> Cc: stable at dpdk.org
> 
> Signed-off-by: Agalya Babu RadhaKrishnan
> <agalyax.babu.radhakrishnan at intel.com>
> ---
>  drivers/bus/fslmc/fslmc_bus.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
> index a2f482516..60c34098c 100644
> --- a/drivers/bus/fslmc/fslmc_bus.c
> +++ b/drivers/bus/fslmc/fslmc_bus.c
> @@ -291,10 +291,13 @@ rte_fslmc_parse(const char *name, void *addr)
>  		goto err_out;
>  	}
> 
> -	if (addr)
> +	if (addr) {
>  		strcpy(addr, sep);
> +		if (!sep_exists && sep)
> +			free(sep);
> +		return 0;
> +	}
> 
> -	return 0;
>  err_out:
>  	if (!sep_exists && sep)
>  		free(sep);
> --
> 2.14.1



More information about the stable mailing list