* [PATCH][next] clocksource: davinci-timer: fix memory leak of clockevent on error return
@ 2019-06-17 11:31 Colin King
2019-06-24 8:28 ` Bartosz Golaszewski
0 siblings, 1 reply; 5+ messages in thread
From: Colin King @ 2019-06-17 11:31 UTC (permalink / raw)
To: Bartosz Golaszewski, Daniel Lezcano, Thomas Gleixner
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Currently when the call to request_irq falls there is a memory leak of
clockevent on the error return path. Fix this by kfree'ing clockevent.
Addresses-Coverity: ("Resource leak")
Fixes: fe3b8194f274 ("clocksource: davinci-timer: 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 a9ca02390b66..8512f12e250a 100644
--- a/drivers/clocksource/timer-davinci.c
+++ b/drivers/clocksource/timer-davinci.c
@@ -300,6 +300,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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH][next] clocksource: davinci-timer: fix memory leak of clockevent on error return
2019-06-17 11:31 [PATCH][next] clocksource: davinci-timer: fix memory leak of clockevent on error return Colin King
@ 2019-06-24 8:28 ` Bartosz Golaszewski
2019-06-24 9:03 ` Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2019-06-24 8:28 UTC (permalink / raw)
To: Colin King; +Cc: Daniel Lezcano, Thomas Gleixner, kernel-janitors, LKML
pon., 17 cze 2019 o 13:31 Colin King <colin.king@canonical.com> napisał(a):
>
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently when the call to request_irq falls there is a memory leak of
> clockevent on the error return path. Fix this by kfree'ing clockevent.
>
> Addresses-Coverity: ("Resource leak")
> Fixes: fe3b8194f274 ("clocksource: davinci-timer: 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 a9ca02390b66..8512f12e250a 100644
> --- a/drivers/clocksource/timer-davinci.c
> +++ b/drivers/clocksource/timer-davinci.c
> @@ -300,6 +300,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 Colin,
I omitted the error checking in this driver on purpose - it doesn't
make sense as the system won't boot without a timer.
Bart
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][next] clocksource: davinci-timer: fix memory leak of clockevent on error return
2019-06-24 8:28 ` Bartosz Golaszewski
@ 2019-06-24 9:03 ` Dan Carpenter
2019-06-24 9:04 ` Bartosz Golaszewski
2019-06-24 9:07 ` Colin Ian King
0 siblings, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2019-06-24 9:03 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Colin King, Daniel Lezcano, Thomas Gleixner, kernel-janitors, LKML
On Mon, Jun 24, 2019 at 10:28:10AM +0200, Bartosz Golaszewski wrote:
> pon., 17 cze 2019 o 13:31 Colin King <colin.king@canonical.com> napisał(a):
> >
> > From: Colin Ian King <colin.king@canonical.com>
> >
> > Currently when the call to request_irq falls there is a memory leak of
> > clockevent on the error return path. Fix this by kfree'ing clockevent.
> >
> > Addresses-Coverity: ("Resource leak")
> > Fixes: fe3b8194f274 ("clocksource: davinci-timer: 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 a9ca02390b66..8512f12e250a 100644
> > --- a/drivers/clocksource/timer-davinci.c
> > +++ b/drivers/clocksource/timer-davinci.c
> > @@ -300,6 +300,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 Colin,
>
> I omitted the error checking in this driver on purpose - it doesn't
> make sense as the system won't boot without a timer.
One way to silence these static checker warnings is to use
"GFP_KERNEL | __GFP_NOFAIL".
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][next] clocksource: davinci-timer: fix memory leak of clockevent on error return
2019-06-24 9:03 ` Dan Carpenter
@ 2019-06-24 9:04 ` Bartosz Golaszewski
2019-06-24 9:07 ` Colin Ian King
1 sibling, 0 replies; 5+ messages in thread
From: Bartosz Golaszewski @ 2019-06-24 9:04 UTC (permalink / raw)
To: Dan Carpenter
Cc: Bartosz Golaszewski, Colin King, Daniel Lezcano, Thomas Gleixner,
kernel-janitors, LKML
pon., 24 cze 2019 o 11:04 Dan Carpenter <dan.carpenter@oracle.com> napisał(a):
>
> On Mon, Jun 24, 2019 at 10:28:10AM +0200, Bartosz Golaszewski wrote:
> > pon., 17 cze 2019 o 13:31 Colin King <colin.king@canonical.com> napisał(a):
> > >
> > > From: Colin Ian King <colin.king@canonical.com>
> > >
> > > Currently when the call to request_irq falls there is a memory leak of
> > > clockevent on the error return path. Fix this by kfree'ing clockevent.
> > >
> > > Addresses-Coverity: ("Resource leak")
> > > Fixes: fe3b8194f274 ("clocksource: davinci-timer: 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 a9ca02390b66..8512f12e250a 100644
> > > --- a/drivers/clocksource/timer-davinci.c
> > > +++ b/drivers/clocksource/timer-davinci.c
> > > @@ -300,6 +300,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 Colin,
> >
> > I omitted the error checking in this driver on purpose - it doesn't
> > make sense as the system won't boot without a timer.
>
> One way to silence these static checker warnings is to use
> "GFP_KERNEL | __GFP_NOFAIL".
>
> regards,
> dan carpenter
>
Noted, I'll be sending a new version of this driver to Daniel anyway,
so I'll include it.
Thanks,
Bart
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH][next] clocksource: davinci-timer: fix memory leak of clockevent on error return
2019-06-24 9:03 ` Dan Carpenter
2019-06-24 9:04 ` Bartosz Golaszewski
@ 2019-06-24 9:07 ` Colin Ian King
1 sibling, 0 replies; 5+ messages in thread
From: Colin Ian King @ 2019-06-24 9:07 UTC (permalink / raw)
To: Dan Carpenter, Bartosz Golaszewski
Cc: Daniel Lezcano, Thomas Gleixner, kernel-janitors, LKML
On 24/06/2019 10:03, Dan Carpenter wrote:
> On Mon, Jun 24, 2019 at 10:28:10AM +0200, Bartosz Golaszewski wrote:
>> pon., 17 cze 2019 o 13:31 Colin King <colin.king@canonical.com> napisał(a):
>>>
>>> From: Colin Ian King <colin.king@canonical.com>
>>>
>>> Currently when the call to request_irq falls there is a memory leak of
>>> clockevent on the error return path. Fix this by kfree'ing clockevent.
>>>
>>> Addresses-Coverity: ("Resource leak")
>>> Fixes: fe3b8194f274 ("clocksource: davinci-timer: 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 a9ca02390b66..8512f12e250a 100644
>>> --- a/drivers/clocksource/timer-davinci.c
>>> +++ b/drivers/clocksource/timer-davinci.c
>>> @@ -300,6 +300,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 Colin,
>>
>> I omitted the error checking in this driver on purpose - it doesn't
>> make sense as the system won't boot without a timer.
>
> One way to silence these static checker warnings is to use
> "GFP_KERNEL | __GFP_NOFAIL".
/me notes that down to for future reference, thanks again Dan for your
wise input.
>
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-06-24 9:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-17 11:31 [PATCH][next] clocksource: davinci-timer: fix memory leak of clockevent on error return Colin King
2019-06-24 8:28 ` Bartosz Golaszewski
2019-06-24 9:03 ` Dan Carpenter
2019-06-24 9:04 ` Bartosz Golaszewski
2019-06-24 9:07 ` Colin Ian King
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).