test-pmd: fix memory leaks when mtr policer actions update fails

Message ID 1590232871-21464-1-git-send-email-wangyunjian@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Cristian Dumitrescu
Headers
Series test-pmd: fix memory leaks when mtr policer actions update fails |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing fail Testing issues
ci/travis-robot success Travis build: passed

Commit Message

Yunjian Wang May 23, 2020, 11:21 a.m. UTC
  From: Yunjian Wang <wangyunjian@huawei.com>

Fix memory leaks reported by Coverity.

Fixes: e63b50162aa3 ("app/testpmd: clean metering and policing commands")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 app/test-pmd/cmdline_mtr.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Thomas Monjalon May 24, 2020, 4:07 p.m. UTC | #1
23/05/2020 13:21, wangyunjian:
> From: Yunjian Wang <wangyunjian@huawei.com>
> 
> Fix memory leaks reported by Coverity.

Please add the Coverity ID with the syntax "Coverity issue:".

> 
> Fixes: e63b50162aa3 ("app/testpmd: clean metering and policing commands")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
  
Yunjian Wang May 25, 2020, 1:45 a.m. UTC | #2
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Monday, May 25, 2020 12:08 AM
> To: wangyunjian <wangyunjian@huawei.com>
> Cc: dev@dpdk.org; Lilijun (Jerry) <jerry.lilijun@huawei.com>; xudingke
> <xudingke@huawei.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] test-pmd: fix memory leaks when mtr policer
> actions update fails
> 
> 23/05/2020 13:21, wangyunjian:
> > From: Yunjian Wang <wangyunjian@huawei.com>
> >
> > Fix memory leaks reported by Coverity.
> 
> Please add the Coverity ID with the syntax "Coverity issue:".

This problem was found by Huawei internal Coverity. So I didn't add the Coverity ID.
I will update the description to "This patch fixes the huawei internal coverity reported
resource leak issue." in v2.

Thanks
Yunjian
> 
> >
> > Fixes: e63b50162aa3 ("app/testpmd: clean metering and policing
> commands")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> 
>
  

Patch

diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
index caa7e9864..ee16244de 100644
--- a/app/test-pmd/cmdline_mtr.c
+++ b/app/test-pmd/cmdline_mtr.c
@@ -1262,6 +1262,7 @@  static void cmd_set_port_meter_policer_action_parsed(void *parsed_result,
 	ret = rte_mtr_policer_actions_update(port_id, mtr_id,
 		action_mask, actions, &error);
 	if (ret != 0) {
+		free(actions);
 		print_err_msg(&error);
 		return;
 	}