All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3] clocksource/timer-imx-gpt: Preventing resource leakage in error case.
@ 2016-09-23 11:57 Arvind Yadav
  2016-09-23 16:41 ` Thomas Gleixner
  0 siblings, 1 reply; 3+ messages in thread
From: Arvind Yadav @ 2016-09-23 11:57 UTC (permalink / raw)
  To: baohua, daniel.lezcano, tglx; +Cc: linux-kernel

-Free previously allocated memory.
-Unmap I/O memory from kernel address space.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/clocksource/timer-imx-gpt.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/clocksource/timer-imx-gpt.c b/drivers/clocksource/timer-imx-gpt.c
index f595460..31cfccf 100644
--- a/drivers/clocksource/timer-imx-gpt.c
+++ b/drivers/clocksource/timer-imx-gpt.c
@@ -489,12 +489,16 @@ static int __init mxc_timer_init_dt(struct device_node *np,  enum imx_gpt_type t
 		return -ENOMEM;
 
 	imxtm->base = of_iomap(np, 0);
-	if (!imxtm->base)
-		return -ENXIO;
+	if (!imxtm->base) {
+		ret = -ENXIO;
+		goto error_free;
+	}
 
 	imxtm->irq = irq_of_parse_and_map(np, 0);
-	if (imxtm->irq <= 0)
-		return -EINVAL;
+	if (imxtm->irq <= 0) {
+		ret = -EINVAL;
+		goto error_iounmap;
+	}
 
 	imxtm->clk_ipg = of_clk_get_by_name(np, "ipg");
 
@@ -506,12 +510,19 @@ static int __init mxc_timer_init_dt(struct device_node *np,  enum imx_gpt_type t
 	imxtm->type = type;
 
 	ret = _mxc_timer_init(imxtm);
-	if (ret)
-		return ret;
+	if (ret) {
+		goto error_iounmap;
+	}
 
 	initialized = 1;
 
 	return 0;
+
+error_iounmap:
+	iounmap(imxtm->base);
+error_kfree:
+	kfree(imxtm);
+	return ret;
 }
 
 static int __init imx1_timer_init_dt(struct device_node *np)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V3] clocksource/timer-imx-gpt: Preventing resource leakage in error case.
  2016-09-23 11:57 [PATCH V3] clocksource/timer-imx-gpt: Preventing resource leakage in error case Arvind Yadav
@ 2016-09-23 16:41 ` Thomas Gleixner
  2016-09-24  7:40   ` arvind Yadav
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Gleixner @ 2016-09-23 16:41 UTC (permalink / raw)
  To: Arvind Yadav; +Cc: baohua, daniel.lezcano, LKML

On Fri, 23 Sep 2016, Arvind Yadav wrote:

So last time (V2) you had a almost perfect subject line:

  clocksrouce/timer-imz-gpt: Prevent resource leaks in error path

The only issue was the clocksrcouce typo. Now you made it:

  clocksource/timer-imx-gpt: Preventing resource leakage in error case.

Documentation/SubmittingPatches says:

 Describe your changes in imperative mood ... as if you are giving orders
 to the codebase to change its behaviour.

 "Preventing" is not imperative and the above is not a proper sentence,
 while the V2 one is.

>  	ret = _mxc_timer_init(imxtm);
> -	if (ret)
> -		return ret;
> +	if (ret) {
> +		goto error_iounmap;
> +	}

Further Documentation/SubmittingPatches also tells you which tools to use
_before_ submission. If you'd used them then the above change would look
different. You surely can figure that out yourself.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V3] clocksource/timer-imx-gpt: Preventing resource leakage in error case.
  2016-09-23 16:41 ` Thomas Gleixner
@ 2016-09-24  7:40   ` arvind Yadav
  0 siblings, 0 replies; 3+ messages in thread
From: arvind Yadav @ 2016-09-24  7:40 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: baohua, daniel.lezcano, LKML

Thanks for help and suggestion.
I am looking 'Documentation/SubmittingPatches'.

Thanks
	-Arvind Yadav


On Friday 23 September 2016 10:11 PM, Thomas Gleixner wrote:
> On Fri, 23 Sep 2016, Arvind Yadav wrote:
>
> So last time (V2) you had a almost perfect subject line:
>
>    clocksrouce/timer-imz-gpt: Prevent resource leaks in error path
>
> The only issue was the clocksrcouce typo. Now you made it:
>
>    clocksource/timer-imx-gpt: Preventing resource leakage in error case.
>
> Documentation/SubmittingPatches says:
>
>   Describe your changes in imperative mood ... as if you are giving orders
>   to the codebase to change its behaviour.
>
>   "Preventing" is not imperative and the above is not a proper sentence,
>   while the V2 one is.
>
>>   	ret = _mxc_timer_init(imxtm);
>> -	if (ret)
>> -		return ret;
>> +	if (ret) {
>> +		goto error_iounmap;
>> +	}
> Further Documentation/SubmittingPatches also tells you which tools to use
> _before_ submission. If you'd used them then the above change would look
> different. You surely can figure that out yourself.
>
> Thanks,
>
> 	tglx
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-24  7:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-23 11:57 [PATCH V3] clocksource/timer-imx-gpt: Preventing resource leakage in error case Arvind Yadav
2016-09-23 16:41 ` Thomas Gleixner
2016-09-24  7:40   ` arvind Yadav

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.