DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] app/testpmd: fix memory leak for dscp table
@ 2022-06-28 13:29 Jasvinder Singh
  2022-06-29 15:37 ` Morrissey, Sean
  2022-06-29 17:30 ` Singh, Aman Deep
  0 siblings, 2 replies; 7+ messages in thread
From: Jasvinder Singh @ 2022-06-28 13:29 UTC (permalink / raw)
  To: dev; +Cc: aman.deep.singh, yuying.zhang, sean.morrissey, stable

This patch fixes memory leak reported by coverity.

Coverity issue: 379220
Fixes: 9f5488e326d3 ("app/testpmd: support different input color method")

Cc: stable@dpdk.org

Signed-off-by: Jasvinder Singh <jasvinder.singh@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;
+	}
 
 	i = 0;
 	while (1) {
@@ -144,6 +146,7 @@ parse_input_color_table_entries(char *str, enum rte_color **dscp_table,
 			vlan[i++] = RTE_COLOR_RED;
 		else {
 			free(vlan);
+			free(*dscp_table);
 			return -1;
 		}
 		if (i == MAX_VLAN_TABLE_ENTRIES)
@@ -152,6 +155,7 @@ parse_input_color_table_entries(char *str, enum rte_color **dscp_table,
 		token = strtok_r(str, PARSE_DELIMITER, &str);
 		if (token == NULL) {
 			free(vlan);
+			free(*dscp_table);
 			return -1;
 		}
 	}
-- 
2.34.3


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] app/testpmd: fix memory leak for dscp table
  2022-06-28 13:29 [PATCH] app/testpmd: fix memory leak for dscp table Jasvinder Singh
@ 2022-06-29 15:37 ` Morrissey, Sean
  2022-06-29 16:53   ` Singh, Aman Deep
  2022-06-29 17:30 ` Singh, Aman Deep
  1 sibling, 1 reply; 7+ messages in thread
From: Morrissey, Sean @ 2022-06-29 15:37 UTC (permalink / raw)
  To: Jasvinder Singh, dev; +Cc: aman.deep.singh, yuying.zhang, stable

Reviewed-by: Sean Morrissey <sean.morrissey@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@dpdk.org
>
> Signed-off-by: Jasvinder Singh <jasvinder.singh@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;
> +	}
>   
>   	i = 0;
>   	while (1) {
> @@ -144,6 +146,7 @@ parse_input_color_table_entries(char *str, enum rte_color **dscp_table,
>   			vlan[i++] = RTE_COLOR_RED;
>   		else {
>   			free(vlan);
> +			free(*dscp_table);
>   			return -1;
>   		}
>   		if (i == MAX_VLAN_TABLE_ENTRIES)
> @@ -152,6 +155,7 @@ parse_input_color_table_entries(char *str, enum rte_color **dscp_table,
>   		token = strtok_r(str, PARSE_DELIMITER, &str);
>   		if (token == NULL) {
>   			free(vlan);
> +			free(*dscp_table);
>   			return -1;
>   		}
>   	}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] app/testpmd: fix memory leak for dscp table
  2022-06-29 15:37 ` Morrissey, Sean
@ 2022-06-29 16:53   ` Singh, Aman Deep
  2022-06-29 17:24     ` Singh, Jasvinder
  0 siblings, 1 reply; 7+ messages in thread
From: Singh, Aman Deep @ 2022-06-29 16:53 UTC (permalink / raw)
  To: Morrissey, Sean, Jasvinder Singh, dev; +Cc: yuying.zhang, stable

Hi Jasvinder,

Thanks for the patch.


On 6/29/2022 9:07 PM, Morrissey, Sean wrote:
> Reviewed-by: Sean Morrissey <sean.morrissey@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@dpdk.org
>>
>> Signed-off-by: Jasvinder Singh <jasvinder.singh@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;

>>         i = 0;
>>       while (1) {
>> @@ -144,6 +146,7 @@ parse_input_color_table_entries(char *str, enum 
>> rte_color **dscp_table,
>>               vlan[i++] = RTE_COLOR_RED;
>>           else {
>>               free(vlan);
>> +            free(*dscp_table);
>>               return -1;
>>           }
>>           if (i == MAX_VLAN_TABLE_ENTRIES)
>> @@ -152,6 +155,7 @@ parse_input_color_table_entries(char *str, enum 
>> rte_color **dscp_table,
>>           token = strtok_r(str, PARSE_DELIMITER, &str);
>>           if (token == NULL) {
>>               free(vlan);
>> +            free(*dscp_table);
>>               return -1;
>>           }
>>       }


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH] app/testpmd: fix memory leak for dscp table
  2022-06-29 16:53   ` Singh, Aman Deep
@ 2022-06-29 17:24     ` Singh, Jasvinder
  0 siblings, 0 replies; 7+ messages in thread
From: Singh, Jasvinder @ 2022-06-29 17:24 UTC (permalink / raw)
  To: Singh, Aman Deep, Morrissey, Sean, dev; +Cc: Zhang, Yuying, stable



> -----Original Message-----
> From: Singh, Aman Deep <aman.deep.singh@intel.com>
> Sent: Wednesday, June 29, 2022 5:53 PM
> To: Morrissey, Sean <sean.morrissey@intel.com>; Singh, Jasvinder
> <jasvinder.singh@intel.com>; dev@dpdk.org
> Cc: Zhang, Yuying <yuying.zhang@intel.com>; stable@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@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@dpdk.org
> >>
> >> Signed-off-by: Jasvinder Singh <jasvinder.singh@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.  

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] app/testpmd: fix memory leak for dscp table
  2022-06-28 13:29 [PATCH] app/testpmd: fix memory leak for dscp table Jasvinder Singh
  2022-06-29 15:37 ` Morrissey, Sean
@ 2022-06-29 17:30 ` Singh, Aman Deep
  2022-07-06 14:32   ` Andrew Rybchenko
  1 sibling, 1 reply; 7+ messages in thread
From: Singh, Aman Deep @ 2022-06-29 17:30 UTC (permalink / raw)
  To: Jasvinder Singh, dev; +Cc: yuying.zhang, sean.morrissey, stable



On 6/28/2022 6:59 PM, 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@dpdk.org
>
> Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>

Acked-by: Aman Singh<aman.deep.singh@intel.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] app/testpmd: fix memory leak for dscp table
  2022-06-29 17:30 ` Singh, Aman Deep
@ 2022-07-06 14:32   ` Andrew Rybchenko
  2022-07-07 12:39     ` Andrew Rybchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Rybchenko @ 2022-07-06 14:32 UTC (permalink / raw)
  To: Singh, Aman Deep, Jasvinder Singh, dev
  Cc: yuying.zhang, sean.morrissey, stable, Thomas Monjalon

In summary: dscp -> DSCP

On 6/29/22 20:30, Singh, Aman Deep wrote:
> 
> 
> On 6/28/2022 6:59 PM, 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@dpdk.org
>>
>> Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
> 
> Acked-by: Aman Singh<aman.deep.singh@intel.com>
> 

Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] app/testpmd: fix memory leak for dscp table
  2022-07-06 14:32   ` Andrew Rybchenko
@ 2022-07-07 12:39     ` Andrew Rybchenko
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Rybchenko @ 2022-07-07 12:39 UTC (permalink / raw)
  To: Singh, Aman Deep, Jasvinder Singh, dev
  Cc: yuying.zhang, sean.morrissey, stable, Thomas Monjalon

On 7/6/22 17:32, Andrew Rybchenko wrote:
> In summary: dscp -> DSCP
> 
> On 6/29/22 20:30, Singh, Aman Deep wrote:
>>
>>
>> On 6/28/2022 6:59 PM, 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@dpdk.org
>>>
>>> Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
>>
>> Acked-by: Aman Singh<aman.deep.singh@intel.com>
>>
> 
> Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>

Applied to dpdk-next-net/main, thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-07-07 12:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-28 13:29 [PATCH] app/testpmd: fix memory leak for dscp table Jasvinder Singh
2022-06-29 15:37 ` Morrissey, Sean
2022-06-29 16:53   ` Singh, Aman Deep
2022-06-29 17:24     ` Singh, Jasvinder
2022-06-29 17:30 ` Singh, Aman Deep
2022-07-06 14:32   ` Andrew Rybchenko
2022-07-07 12:39     ` Andrew Rybchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).