[dpdk-dev] eal: change to prevent memory leak in eal debug
Commit Message
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(+)
Comments
2015-09-21 17:00, Zhe Tao:
> Free the memory allocated by the backtrace_symbols
> to prevent the memory leak
>
> Signed-off-by: Zhe Tao <zhe.tao@intel.com>
Applied, with reverted comparisons:
WARNING:CONSTANT_COMPARISON: Comparisons should place the constant on the right side of the test
+ if (NULL == symb)
@@ -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 */
@@ -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 */