Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1489974 > unrolled thread

[PATCH V3] clocksource/timer-imx-gpt: Preventing resource leakage in error case.

Started byArvind Yadav <arvind.yadav.cs@gmail.com>
First post2016-09-23 14:00 +0200
Last post2016-09-24 09:50 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH V3] clocksource/timer-imx-gpt: Preventing resource leakage in error case. Arvind Yadav <arvind.yadav.cs@gmail.com> - 2016-09-23 14:00 +0200
    Re: [PATCH V3] clocksource/timer-imx-gpt: Preventing resource leakage  in error case. Thomas Gleixner <tglx@linutronix.de> - 2016-09-23 18:50 +0200
      Re: [PATCH V3] clocksource/timer-imx-gpt: Preventing resource leakage  in error case. arvind Yadav <arvind.yadav.cs@gmail.com> - 2016-09-24 09:50 +0200

#1489974 — [PATCH V3] clocksource/timer-imx-gpt: Preventing resource leakage in error case.

FromArvind Yadav <arvind.yadav.cs@gmail.com>
Date2016-09-23 14:00 +0200
Subject[PATCH V3] clocksource/timer-imx-gpt: Preventing resource leakage in error case.
Message-ID<skxj4-38t-27@gated-at.bofh.it>
-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

[toc] | [next] | [standalone]


#1490324 — Re: [PATCH V3] clocksource/timer-imx-gpt: Preventing resource leakage in error case.

FromThomas Gleixner <tglx@linutronix.de>
Date2016-09-23 18:50 +0200
SubjectRe: [PATCH V3] clocksource/timer-imx-gpt: Preventing resource leakage in error case.
Message-ID<skBPI-6j6-37@gated-at.bofh.it>
In reply to#1489974
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

[toc] | [prev] | [next] | [standalone]


#1490584 — Re: [PATCH V3] clocksource/timer-imx-gpt: Preventing resource leakage in error case.

Fromarvind Yadav <arvind.yadav.cs@gmail.com>
Date2016-09-24 09:50 +0200
SubjectRe: [PATCH V3] clocksource/timer-imx-gpt: Preventing resource leakage in error case.
Message-ID<skPSF-6AA-5@gated-at.bofh.it>
In reply to#1490324
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
>
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web