From: xkernel.wang@foxmail.com
To: rostedt@goodmis.org, mingo@redhat.com
Cc: linux-kernel@vger.kernel.org, Xiaoke Wang <xkernel.wang@foxmail.com>
Subject: [PATCH] tracing/histogram: fix a potential memory leak for kstrdup()
Date: Tue, 25 Jan 2022 12:07:15 +0800 [thread overview]
Message-ID: <tencent_C52895FD37802832A3E5B272D05008866F0A@qq.com> (raw)
From: Xiaoke Wang <xkernel.wang@foxmail.com>
kfree() is missing on an error path to free the memory allocated by
kstrdup():
> p = param = kstrdup(data->params[i], GFP_KERNEL);
So it is better to free it via kfree(p).
Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
---
kernel/trace/trace_events_hist.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index f01e442..1fac14c 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -3578,6 +3578,7 @@ static int trace_action_create(struct hist_trigger_data *hist_data,
var_ref_idx = find_var_ref_idx(hist_data, var_ref);
if (WARN_ON(var_ref_idx < 0)) {
+ kfree(p);
ret = var_ref_idx;
goto err;
}
--
next reply other threads:[~2022-01-25 4:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-25 4:07 xkernel.wang [this message]
2022-01-25 14:32 ` [PATCH] tracing/histogram: fix a potential memory leak for kstrdup() Steven Rostedt
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=tencent_C52895FD37802832A3E5B272D05008866F0A@qq.com \
--to=xkernel.wang@foxmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.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).