From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
Maxime Ripard <maxime.ripard@free-electrons.com>,
Chen-Yu Tsai <wens@csie.org>,
linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] rtc: sun6i: fix memory leak
Date: Wed, 27 Sep 2017 15:25:23 +0200 [thread overview]
Message-ID: <20170927132523.u6miojeax67idtsj@piout.net> (raw)
In-Reply-To: <1505652190-4942-1-git-send-email-sudipm.mukherjee@gmail.com>
Hi,
On 17/09/2017 at 13:43:10 +0100, Sudip Mukherjee wrote:
> If 'clk_data' is not allocated we returned but we failed to free 'rtc'.
>
> Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
> ---
> drivers/rtc/rtc-sun6i.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c
> index 3d2216c..5bc28ee 100644
> --- a/drivers/rtc/rtc-sun6i.c
> +++ b/drivers/rtc/rtc-sun6i.c
> @@ -201,8 +201,10 @@ static void __init sun6i_rtc_clk_init(struct device_node *node)
>
> clk_data = kzalloc(sizeof(*clk_data) + (sizeof(*clk_data->hws) * 2),
> GFP_KERNEL);
> - if (!clk_data)
> + if (!clk_data) {
> + kfree(rtc);
> return;
> + }
Please also fix the other occurrence of the issue in the same function.
>
> spin_lock_init(&rtc->lock);
>
> --
> 2.7.4
>
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
prev parent reply other threads:[~2017-09-27 13:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-17 12:43 Sudip Mukherjee
2017-09-27 13:25 ` Alexandre Belloni [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=20170927132523.u6miojeax67idtsj@piout.net \
--to=alexandre.belloni@free-electrons.com \
--cc=a.zummo@towertech.it \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=maxime.ripard@free-electrons.com \
--cc=sudipm.mukherjee@gmail.com \
--cc=wens@csie.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
all inboxes | Powered by JetHome®