From: Thomas Gleixner <tglx@linutronix.de>
To: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>,
Colin King <colin.king@canonical.com>,
LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] clocksource/drivers/davinci: fix memory leak on clockevent on error return
Date: Tue, 12 Nov 2019 00:37:41 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.21.1911120033220.1833@nanos.tec.linutronix.de> (raw)
In-Reply-To: <CAMpxmJVC5GGhR0z_4CkF7Opfw-5HpEKD8fUrKsgBZTbz0wDd-Q@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1912 bytes --]
Bartosz,
On Sun, 10 Nov 2019, Bartosz Golaszewski wrote:
> sob., 9 lis 2019 o 16:58 Colin King <colin.king@canonical.com> napisał(a):
> >
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > In the case where request_irq fails, the return path does not kfree
> > clockevent and hence we have a memory leak. Fix this by kfree'ing
s/we have/creates/ or whatever verb you prefer.
> > clockevent before returning.
> >
> > Addresses-Coverity: ("Resource leak")
> > Fixes: 721154f972aa ("clocksource/drivers/davinci: Add support for clockevents")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> > drivers/clocksource/timer-davinci.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/clocksource/timer-davinci.c b/drivers/clocksource/timer-davinci.c
> > index 62745c962049..910d4d2f0d64 100644
> > --- a/drivers/clocksource/timer-davinci.c
> > +++ b/drivers/clocksource/timer-davinci.c
> > @@ -299,6 +299,7 @@ int __init davinci_timer_register(struct clk *clk,
> > "clockevent/tim12", clockevent);
> > if (rv) {
> > pr_err("Unable to request the clockevent interrupt");
> > + kfree(clockevent);
> > return rv;
> > }
> >
> > --
> > 2.20.1
> >
>
> Hi Daniel,
>
> this is what I think the third time someone tries to "fix" this
> driver's "memory leaks". I'm not sure what the general approach in
> clocksource is but it doesn't make sense to free resources on
> non-recoverable errors, does it? Should I add a comment about it or
> you'll just take those "fixes" to stop further such submissions?
There are two ways to deal with that:
1) If the error is really unrecoverable, panic right there. No point
to continue.
2) If there is even a minimal chance to survive, free the memory and
return.
Adding a comment is just a useless non-option.
Thanks,
tglx
next prev parent reply other threads:[~2019-11-11 23:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-09 15:58 [PATCH] clocksource/drivers/davinci: fix memory leak on clockevent on error return Colin King
2019-11-10 15:59 ` Bartosz Golaszewski
2019-11-11 23:37 ` Thomas Gleixner [this message]
2019-11-12 8:34 ` Bartosz Golaszewski
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=alpine.DEB.2.21.1911120033220.1833@nanos.tec.linutronix.de \
--to=tglx@linutronix.de \
--cc=bgolaszewski@baylibre.com \
--cc=colin.king@canonical.com \
--cc=daniel.lezcano@linaro.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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).