From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Yi Yang <yiyang13@huawei.com>
Cc: <rostedt@goodmis.org>, <ast@kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fix a potential memleak in rethook_alloc()
Date: Fri, 11 Nov 2022 09:30:50 +0900 [thread overview]
Message-ID: <20221111093050.554a3403256c429d33915ebd@kernel.org> (raw)
In-Reply-To: <20221110104438.88099-1-yiyang13@huawei.com>
On Thu, 10 Nov 2022 18:44:38 +0800
Yi Yang <yiyang13@huawei.com> wrote:
> In rethook_alloc(), the variable rh is not freed or passed out
> if handler is NULL, which could lead to a memleak, fix it.
>
Oops, good catch!
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Thank you!
> Fixes: 54ecbe6f1ed5 ("rethook: Add a generic return hook")
> Signed-off-by: Yi Yang <yiyang13@huawei.com>
> ---
> kernel/trace/rethook.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/trace/rethook.c b/kernel/trace/rethook.c
> index 01df98db2fbe..f50aebc7698e 100644
> --- a/kernel/trace/rethook.c
> +++ b/kernel/trace/rethook.c
> @@ -91,8 +91,10 @@ struct rethook *rethook_alloc(void *data, rethook_handler_t handler, gfp_t gfp,
> {
> struct rethook *rh = kzalloc(sizeof(struct rethook), GFP_KERNEL);
>
> - if (!rh || !handler)
> + if (!rh || !handler) {
> + kfree(rh);
> return NULL;
> + }
>
> rh->data = data;
> rh->handler = handler;
> --
> 2.17.1
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
prev parent reply other threads:[~2022-11-11 0:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-10 10:44 Yi Yang
2022-11-11 0:30 ` Masami Hiramatsu [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=20221111093050.554a3403256c429d33915ebd@kernel.org \
--to=mhiramat@kernel.org \
--cc=ast@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=yiyang13@huawei.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
Powered by JetHome