[PATCH] app/testpmd: fix memory leak for dscp table

Singh, Jasvinder jasvinder.singh at intel.com
Wed Jun 29 19:24:16 CEST 2022



> -----Original Message-----
> From: Singh, Aman Deep <aman.deep.singh at intel.com>
> Sent: Wednesday, June 29, 2022 5:53 PM
> To: Morrissey, Sean <sean.morrissey at intel.com>; Singh, Jasvinder
> <jasvinder.singh at intel.com>; dev at dpdk.org
> Cc: Zhang, Yuying <yuying.zhang at intel.com>; stable at dpdk.org
> Subject: Re: [PATCH] app/testpmd: fix memory leak for dscp table
> 
> Hi Jasvinder,
> 
> Thanks for the patch.
> 
> 
> On 6/29/2022 9:07 PM, Morrissey, Sean wrote:
> > Reviewed-by: Sean Morrissey <sean.morrissey at intel.com>
> >
> > Thanks.
> >
> > On 28/06/2022 14:29, Jasvinder Singh wrote:
> >> This patch fixes memory leak reported by coverity.
> >>
> >> Coverity issue: 379220
> >> Fixes: 9f5488e326d3 ("app/testpmd: support different input color
> >> method")
> >>
> >> Cc: stable at dpdk.org
> >>
> >> Signed-off-by: Jasvinder Singh <jasvinder.singh at intel.com>
> >> ---
> >>   app/test-pmd/cmdline_mtr.c | 6 +++++-
> >>   1 file changed, 5 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
> >> index b92e66cedb..833273da0d 100644
> >> --- a/app/test-pmd/cmdline_mtr.c
> >> +++ b/app/test-pmd/cmdline_mtr.c
> >> @@ -131,8 +131,10 @@ parse_input_color_table_entries(char *str, enum
> >> rte_color **dscp_table,
> >>       /* Allocate memory for vlan table */
> >>       vlan = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES *
> >>           sizeof(enum rte_color));
> >> -    if (vlan == NULL)
> >> +    if (vlan == NULL) {
> >> +        free(*dscp_table);
> >>           return -1;
> >> +    }
> 
> Did we miss one return at line 129, or is it not required-
> 
> 	token = strtok_r(str, PARSE_DELIMITER, &str);
> 	if (token == NULL)
> 		return 0;
> 
No need to free the allocated memory on successful return from the function.  


More information about the stable mailing list