DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] eal: change to prevent memory leak in eal debug
@ 2015-09-21  9:00 Zhe Tao
  2015-10-25 22:41 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Zhe Tao @ 2015-09-21  9:00 UTC (permalink / raw)
  To: dev

Free the memory allocated by the backtrace_symbols
 to prevent the memory leak

Signed-off-by: Zhe Tao <zhe.tao@intel.com>
---
 lib/librte_eal/bsdapp/eal/eal_debug.c   | 6 ++++++
 lib/librte_eal/linuxapp/eal/eal_debug.c | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/lib/librte_eal/bsdapp/eal/eal_debug.c b/lib/librte_eal/bsdapp/eal/eal_debug.c
index 44fc4f3..82d1c81 100644
--- a/lib/librte_eal/bsdapp/eal/eal_debug.c
+++ b/lib/librte_eal/bsdapp/eal/eal_debug.c
@@ -53,11 +53,17 @@ void rte_dump_stack(void)
 
 	size = backtrace(func, BACKTRACE_SIZE);
 	symb = backtrace_symbols(func, size);
+
+	if (NULL == symb)
+		return;
+
 	while (size > 0) {
 		rte_log(RTE_LOG_ERR, RTE_LOGTYPE_EAL,
 			"%d: [%s]\n", size, symb[size - 1]);
 		size --;
 	}
+
+	free(symb);
 }
 
 /* not implemented in this environment */
diff --git a/lib/librte_eal/linuxapp/eal/eal_debug.c b/lib/librte_eal/linuxapp/eal/eal_debug.c
index 44fc4f3..82d1c81 100644
--- a/lib/librte_eal/linuxapp/eal/eal_debug.c
+++ b/lib/librte_eal/linuxapp/eal/eal_debug.c
@@ -53,11 +53,17 @@ void rte_dump_stack(void)
 
 	size = backtrace(func, BACKTRACE_SIZE);
 	symb = backtrace_symbols(func, size);
+
+	if (NULL == symb)
+		return;
+
 	while (size > 0) {
 		rte_log(RTE_LOG_ERR, RTE_LOGTYPE_EAL,
 			"%d: [%s]\n", size, symb[size - 1]);
 		size --;
 	}
+
+	free(symb);
 }
 
 /* not implemented in this environment */
-- 
1.9.3

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

end of thread, other threads:[~2015-10-25 22:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-21  9:00 [dpdk-dev] [PATCH] eal: change to prevent memory leak in eal debug Zhe Tao
2015-10-25 22:41 ` Thomas Monjalon

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).