[dpdk-dev,v2,1/2] app/test-pmd: fix Coverity issues

Message ID 1466436187-5225-2-git-send-email-remy.horton@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Commit Message

Remy Horton June 20, 2016, 3:23 p.m. UTC
  Fixes memory leaks detected by Coverity. These are due to ephemeral
memory allocations not being freed when errors occur.

Coverity issue 127348: Resource leak

Fixes: e2aae1c1ced9 ("ethdev: remove name from extended statistic fetch")

Signed-off-by: Remy Horton <remy.horton@intel.com>
---
 app/test-pmd/config.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

De Lara Guarch, Pablo June 20, 2016, 3:33 p.m. UTC | #1
Hi Remy,

> -----Original Message-----
> From: Horton, Remy
> Sent: Monday, June 20, 2016 4:23 PM
> To: dev@dpdk.org; De Lara Guarch, Pablo
> Subject: [PATCH v2 1/2] app/test-pmd: fix Coverity issues
> 
> Fixes memory leaks detected by Coverity. These are due to ephemeral
> memory allocations not being freed when errors occur.
> 
> Coverity issue 127348: Resource leak
> 
> Fixes: e2aae1c1ced9 ("ethdev: remove name from extended statistic fetch")
> 
> Signed-off-by: Remy Horton <remy.horton@intel.com>

It would be better to change the title, so it says what are you fixing exactly (i.e. testpmd: fix resource leak)
  

Patch

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 10f0a36..cb71c09 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -281,6 +281,7 @@  nic_xstats_display(portid_t port_id)
 	if (cnt_xstats != rte_eth_xstats_get_names(
 			port_id, xstats_names, cnt_xstats)) {
 		printf("Error: Cannot get xstats lookup\n");
+		free(xstats_names);
 		return;
 	}
 
@@ -293,6 +294,8 @@  nic_xstats_display(portid_t port_id)
 	}
 	if (cnt_xstats != rte_eth_xstats_get(port_id, xstats, cnt_xstats)) {
 		printf("Error: Unable to get xstats\n");
+		free(xstats_names);
+		free(xstats);
 		return;
 	}