From: Steven Rostedt <rostedt@goodmis.org>
To: xkernel.wang@foxmail.com
Cc: mingo@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tracing/histogram: fix a potential memory leak for kstrdup()
Date: Tue, 25 Jan 2022 09:32:58 -0500 [thread overview]
Message-ID: <20220125093258.222175c7@gandalf.local.home> (raw)
In-Reply-To: <tencent_C52895FD37802832A3E5B272D05008866F0A@qq.com>
On Tue, 25 Jan 2022 12:07:15 +0800
xkernel.wang@foxmail.com wrote:
> 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).
>
Applied. Thanks,
-- Steve
> 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;
> }
prev parent reply other threads:[~2022-01-25 14:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-25 4:07 xkernel.wang
2022-01-25 14:32 ` Steven Rostedt [this message]
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=20220125093258.222175c7@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=xkernel.wang@foxmail.com \
/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
all inboxes | Powered by JetHome®