[dpdk-dev] dpdk-procinfo: free allocated xstats memory upon failure

Message ID 1475599342-12338-1-git-send-email-reshma.pattan@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Commit Message

Pattan, Reshma Oct. 4, 2016, 4:42 p.m. UTC
  Some of the failures cases inside the nic_xstats_display()
function doesn't free the allocated memory for the xstats and
their names, memory is freed now.

Fixes: e2aae1c1 ("ethdev: remove name from extended statistic fetch")
Fixes: 22561383 ("app: replace dump_cfg by proc_info")

Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
---
 app/proc_info/main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Thomas Monjalon Oct. 12, 2016, 1:28 p.m. UTC | #1
2016-10-04 17:42, Reshma Pattan:
> Some of the failures cases inside the nic_xstats_display()
> function doesn't free the allocated memory for the xstats and
> their names, memory is freed now.
> 
> Fixes: e2aae1c1 ("ethdev: remove name from extended statistic fetch")
> Fixes: 22561383 ("app: replace dump_cfg by proc_info")
> 
> Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>

Applied, thanks
  
Remy Horton Oct. 12, 2016, 1:29 p.m. UTC | #2
On 04/10/2016 17:42, Reshma Pattan wrote:
> Some of the failures cases inside the nic_xstats_display()
> function doesn't free the allocated memory for the xstats and
> their names, memory is freed now.
>
> Fixes: e2aae1c1 ("ethdev: remove name from extended statistic fetch")
> Fixes: 22561383 ("app: replace dump_cfg by proc_info")
>
> Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>

Acked-by: Remy Horton <remy.horton@intel.com>
  

Patch

diff --git a/app/proc_info/main.c b/app/proc_info/main.c
index 8246fb2..2c56d10 100644
--- a/app/proc_info/main.c
+++ b/app/proc_info/main.c
@@ -268,7 +268,7 @@  nic_xstats_display(uint8_t port_id)
 	if (len != rte_eth_xstats_get_names(
 			port_id, xstats_names, len)) {
 		printf("Cannot get xstat names\n");
-		return;
+		goto err;
 	}
 
 	printf("###### NIC extended statistics for port %-2d #########\n",
@@ -278,8 +278,7 @@  nic_xstats_display(uint8_t port_id)
 	ret = rte_eth_xstats_get(port_id, xstats, len);
 	if (ret < 0 || ret > len) {
 		printf("Cannot get xstats\n");
-		free(xstats);
-		return;
+		goto err;
 	}
 
 	for (i = 0; i < len; i++)
@@ -289,6 +288,7 @@  nic_xstats_display(uint8_t port_id)
 
 	printf("%s############################\n",
 			   nic_stats_border);
+err:
 	free(xstats);
 	free(xstats_names);
 }