[dpdk-stable] [PATCH v3] net/softnic: fix memory leak in parsing arguments

Yu, DapengX dapengx.yu at intel.com
Thu Jul 15 03:42:43 CEST 2021



> -----Original Message-----
> From: Singh, Jasvinder <jasvinder.singh at intel.com>
> Sent: Wednesday, July 14, 2021 7:08 PM
> To: Yu, DapengX <dapengx.yu at intel.com>; Dumitrescu, Cristian
> <cristian.dumitrescu at intel.com>
> Cc: dev at dpdk.org; stable at dpdk.org
> Subject: RE: [PATCH v3] net/softnic: fix memory leak in parsing arguments
> 
> <snip>
> 
> > +	free(firmware);
> 
> Memory for firmware is not allocated dynamically, so no need for this.

I have double checked it, at this code snippet, the memory block referenced by the "firmware" pointer is allocated by the strdup() in get_string() function.
The free(firmware) is necessary, and it prevents memory leak.
> 
> <snip>
> 
> >  struct pmd_params {
> > -	const char *name;
> > -	const char *firmware;
> > +	char name[RTE_DEV_NAME_MAX_LEN];
> 
> Please replace " RTE_DEV_NAME_MAX_LEN " with "NAME_SIZE" which is
> already defined in softnic_internals.h

It will be modified in the next version.
> 
> > +	char firmware[PATH_MAX];
> 
> Also, instead of using PATH_MAX, define new macro "SOFTNIC_PATH_MAX
> 4096" in softnic_internals.h

It will be modified in the next version.
> 
> 
> >  	uint16_t conn_port;
> >  	uint32_t cpu_id;
> >  	int sc; /**< Service cores. */
> > --
> > 2.27.0



More information about the stable mailing list