[dpdk-dev] [PATCH] eal: change to prevent memory leak in eal debug
Zhe Tao
zhe.tao at intel.com
Mon Sep 21 11:00:47 CEST 2015
Free the memory allocated by the backtrace_symbols
to prevent the memory leak
Signed-off-by: Zhe Tao <zhe.tao at 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
More information about the dev
mailing list