From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Yu Kuai <yukuai3@huawei.com>,
michal.simek@xilinx.com, tglx@linutronix.de,
soren.brinkmann@xilinx.com
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, yi.zhang@huawei.com,
zhangxiaoxu5@huawei.com
Subject: Re: [PATCH V2] clocksource/drivers/cadence_ttc: fix memory leak in ttc_setup_clockevent()
Date: Thu, 12 Nov 2020 10:59:33 +0100 [thread overview]
Message-ID: <cd03869c-6ad1-1463-d7da-c8500adb32c8@linaro.org> (raw)
In-Reply-To: <20201111011652.328500-1-yukuai3@huawei.com>
On 11/11/2020 02:16, Yu Kuai wrote:
> If clk_notifier_register() failed, ttc_setup_clockevent() will return
> without freeing 'ttcce', which will leak memory.
>
> Fixes: 70504f311d4b ("clocksource/drivers/cadence_ttc: Convert init function to return error")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> Reviewed-by: Michal Simek <michal.simek@xilinx.com>
> ---
> drivers/clocksource/timer-cadence-ttc.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/clocksource/timer-cadence-ttc.c b/drivers/clocksource/timer-cadence-ttc.c
> index 80e960602030..32b9560ce408 100644
> --- a/drivers/clocksource/timer-cadence-ttc.c
> +++ b/drivers/clocksource/timer-cadence-ttc.c
> @@ -426,6 +426,7 @@ static int __init ttc_setup_clockevent(struct clk *clk,
> &ttcce->ttc.clk_rate_change_nb);
> if (err) {
> pr_warn("Unable to register clock notifier.\n");
> + kfree(ttcce);
> return err;
> }
Please fix the error path by adding a label (eg. out_kfree) and jump to
it in case of error everywhere in the function.
out_kfree:
kfree(ttcce);
return err;
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
next prev parent reply other threads:[~2020-11-12 9:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-10 1:15 [PATCH] "clocksource/drivers/cadence_ttc: fix memory leak in ttc_setup_clockevent() Yu Kuai
2020-11-10 10:04 ` Michal Simek
2020-11-10 10:07 ` Michal Simek
2020-11-11 1:16 ` [PATCH V2] clocksource/drivers/cadence_ttc: " Yu Kuai
2020-11-12 9:59 ` Daniel Lezcano [this message]
2020-11-16 7:08 ` [PATCH V3] " Yu Kuai
2020-11-16 13:51 ` [PATCH V4] " Yu Kuai
2020-11-17 9:07 ` Daniel Lezcano
2020-12-03 23:47 ` [tip: timers/core] clocksource/drivers/cadence_ttc: Fix " tip-bot2 for Yu Kuai
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=cd03869c-6ad1-1463-d7da-c8500adb32c8@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@xilinx.com \
--cc=soren.brinkmann@xilinx.com \
--cc=tglx@linutronix.de \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.com \
--cc=zhangxiaoxu5@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;
as well as URLs for NNTP newsgroup(s).