eal: fix memory leak in stack dump
authorZhe Tao <zhe.tao@intel.com>
Mon, 21 Sep 2015 09:00:47 +0000 (17:00 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Sun, 25 Oct 2015 22:38:42 +0000 (23:38 +0100)
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
lib/librte_eal/linuxapp/eal/eal_debug.c

index 44fc4f3..907fbfa 100644 (file)
@@ -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 */
index 44fc4f3..907fbfa 100644 (file)
@@ -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 */