From: Zhe Tao <zhe.tao@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] eal: change to prevent memory leak in eal debug
Date: Mon, 21 Sep 2015 17:00:47 +0800 [thread overview]
Message-ID: <1442826047-4093-1-git-send-email-zhe.tao@intel.com> (raw)
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
next reply other threads:[~2015-09-21 9:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-21 9:00 Zhe Tao [this message]
2015-10-25 22:41 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1442826047-4093-1-git-send-email-zhe.tao@intel.com \
--to=zhe.tao@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).