From: Zhe Tao Date: Mon, 21 Sep 2015 09:00:47 +0000 (+0800) Subject: eal: fix memory leak in stack dump X-Git-Tag: spdx-start~8362 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=faefe2296da86bb95ffbb5a8925b026dc006744c;p=dpdk.git eal: fix memory leak in stack dump Free the memory allocated by the backtrace_symbols to prevent the memory leak. Signed-off-by: Zhe Tao --- diff --git a/lib/librte_eal/bsdapp/eal/eal_debug.c b/lib/librte_eal/bsdapp/eal/eal_debug.c index 44fc4f338b..907fbfa7b8 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 (symb == NULL) + 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 44fc4f338b..907fbfa7b8 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 (symb == NULL) + 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 */