mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Colin King <colin.king@canonical.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Nicolas Saenz Julienne <nsaenzjulienne@suse.de>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	bcm-kernel-feedback-list@broadcom.com,
	linux-kernel@vger.kernel.org,
	linux-rpi-kernel@lists.infradead.org
Cc: kernel-janitors@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] clocksource/drivers/bcm2835_timer: fix memory leak of timer
Date: Fri, 20 Dec 2019 10:58:36 +0100	[thread overview]
Message-ID: <85475b50-5617-1ed0-3fe6-3dbaa18c236c@linaro.org> (raw)
In-Reply-To: <20191219213246.34437-1-colin.king@canonical.com>


Applied, thanks!

On 19/12/2019 22:32, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently when setup_irq fails the error exit path will leak the
> recently allocated timer structure.  Originally the code would
> throw a panic but a later commit changed the behaviour to return
> via the err_iounmap path and hence we now have a memory leak. Fix
> this by adding a err_timer_free error path that kfree's timer.
> 
> Addresses-Coverity: ("Resource Leak")
> Fixes: 524a7f08983d ("clocksource/drivers/bcm2835_timer: Convert init function to return error")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/clocksource/bcm2835_timer.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/clocksource/bcm2835_timer.c b/drivers/clocksource/bcm2835_timer.c
> index 2b196cbfadb6..b235f446ee50 100644
> --- a/drivers/clocksource/bcm2835_timer.c
> +++ b/drivers/clocksource/bcm2835_timer.c
> @@ -121,7 +121,7 @@ static int __init bcm2835_timer_init(struct device_node *node)
>  	ret = setup_irq(irq, &timer->act);
>  	if (ret) {
>  		pr_err("Can't set up timer IRQ\n");
> -		goto err_iounmap;
> +		goto err_timer_free;
>  	}
>  
>  	clockevents_config_and_register(&timer->evt, freq, 0xf, 0xffffffff);
> @@ -130,6 +130,9 @@ static int __init bcm2835_timer_init(struct device_node *node)
>  
>  	return 0;
>  
> +err_timer_free:
> +	kfree(timer);
> +
>  err_iounmap:
>  	iounmap(base);
>  	return ret;
> 


-- 
 <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


  reply	other threads:[~2019-12-20  9:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-19 21:32 Colin King
2019-12-20  9:58 ` Daniel Lezcano [this message]
2020-01-16 21:31 ` [tip: timers/core] clocksource/drivers/bcm2835_timer: Fix " tip-bot2 for Colin Ian King

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=85475b50-5617-1ed0-3fe6-3dbaa18c236c@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=colin.king@canonical.com \
    --cc=f.fainelli@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=nsaenzjulienne@suse.de \
    --cc=rjui@broadcom.com \
    --cc=sbranden@broadcom.com \
    --cc=tglx@linutronix.de \
    /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®