public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: Michal Simek <michal.simek@xilinx•com>
To: Navid Emamdoost <navid.emamdoost@gmail•com>, michal.simek@xilinx•com
Cc: Daniel Lezcano <daniel.lezcano@linaro•org>,
	kjlu@umn•edu, linux-kernel@vger•kernel.org, emamd001@umn•edu,
	Markus.Elfring@web•de, smccaman@umn•edu,
	Thomas Gleixner <tglx@linutronix•de>,
	linux-arm-kernel@lists•infradead.org
Subject: Re: [PATCH v2] clocksource/drivers: Fix memory leak in ttc_setup_clockevent
Date: Wed, 23 Oct 2019 09:32:59 +0200	[thread overview]
Message-ID: <9939e8bb-4e3d-fddf-3c02-66d55a6796ff@xilinx.com> (raw)
In-Reply-To: <20191023043139.31183-1-navid.emamdoost@gmail.com>

On 23. 10. 19 6:31, Navid Emamdoost wrote:
> In the implementation of ttc_setup_clockevent() release the allocated
> memory for ttcce if clk_notifier_register() fails.
> 
> Fixes: 70504f311d4b ("clocksource/drivers/cadence_ttc: Convert init function to return error")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail•com>
> ---
> Changes in v2:
> 	- Added goto label for error handling
> 	- Update description and fix typo
> 
>  drivers/clocksource/timer-cadence-ttc.c | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/clocksource/timer-cadence-ttc.c b/drivers/clocksource/timer-cadence-ttc.c
> index 88fe2e9ba9a3..0caacbc67102 100644
> --- a/drivers/clocksource/timer-cadence-ttc.c
> +++ b/drivers/clocksource/timer-cadence-ttc.c
> @@ -411,10 +411,8 @@ static int __init ttc_setup_clockevent(struct clk *clk,
>  	ttcce->ttc.clk = clk;
>  
>  	err = clk_prepare_enable(ttcce->ttc.clk);
> -	if (err) {
> -		kfree(ttcce);
> -		return err;
> -	}
> +	if (err)
> +		goto release_ttcce;
>  
>  	ttcce->ttc.clk_rate_change_nb.notifier_call =
>  		ttc_rate_change_clockevent_cb;
> @@ -424,7 +422,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");
> -		return err;
> +		goto release_ttcce;
>  	}
>  
>  	ttcce->ttc.freq = clk_get_rate(ttcce->ttc.clk);
> @@ -453,15 +451,18 @@ static int __init ttc_setup_clockevent(struct clk *clk,
>  
>  	err = request_irq(irq, ttc_clock_event_interrupt,
>  			  IRQF_TIMER, ttcce->ce.name, ttcce);
> -	if (err) {
> -		kfree(ttcce);
> -		return err;
> -	}
> +	if (err)
> +		goto release_ttcce;
>  
>  	clockevents_config_and_register(&ttcce->ce,
>  			ttcce->ttc.freq / PRESCALE, 1, 0xfffe);
>  
>  	return 0;
> +
> +release_ttcce:
> +
> +	kfree(ttcce);
> +	return err;
>  }
>  
>  /**
> 

Acked-by: Michal Simek <michal.simek@xilinx•com>

Thanks,
Michal


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists•infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-10-23  7:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-21 20:18 [PATCH] clocksource/drivers: Fix memory leak in ttc_setup_clockevent Navid Emamdoost
2019-10-22  8:26 ` Markus Elfring
2019-10-22  8:51   ` Michal Simek
2019-10-23  4:31     ` [PATCH v2] " Navid Emamdoost
2019-10-23  7:32       ` Michal Simek [this message]
2019-10-23  8:00       ` Markus Elfring
2019-10-23  4:47     ` [PATCH] clocksource/drivers: Fix error handling in ttc_setup_clocksource Navid Emamdoost
2019-10-23  7:24       ` Markus Elfring
2019-10-23  8:20       ` Markus Elfring
2019-10-23 10:31       ` Markus Elfring
2019-12-14 22:54       ` Navid Emamdoost
2019-12-16 13:41         ` Daniel Lezcano
2019-12-17 15:09           ` Michal Simek
2019-10-23  4:50     ` [PATCH] clocksource/drivers: Fix memory leak in ttc_setup_clockevent Navid Emamdoost

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=9939e8bb-4e3d-fddf-3c02-66d55a6796ff@xilinx.com \
    --to=michal.simek@xilinx$(echo .)com \
    --cc=Markus.Elfring@web$(echo .)de \
    --cc=daniel.lezcano@linaro$(echo .)org \
    --cc=emamd001@umn$(echo .)edu \
    --cc=kjlu@umn$(echo .)edu \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=navid.emamdoost@gmail$(echo .)com \
    --cc=smccaman@umn$(echo .)edu \
    --cc=tglx@linutronix$(echo .)de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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