clocksource/timer-imx-gpt: Preventing resource leakage in error case.
Subsystems (2)
PATCH v3 1/1 clocksource/timer-imx-gpt: Preventing resource leakage in error case.
-Free previously allocated memory.
-Unmap I/O memory from kernel address space.
--- drivers/clocksource/timer-imx-gpt.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/clocksource/timer-imx-gpt.c +17 -6
@@ -489,12 +489,16 @@ static int __init mxc_timer_init_dt(struct device_node *np, enum imx_gpt_type treturn -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)
Signature · 1 line
2.7.4
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.
drivers/clocksource/timer-imx-gpt.c static int __init mxc_timer_init_dt(struct device_node *np, enum imx_gpt_type t · line 515
Quoted 6 lines
drivers/clocksource/timer-imx-gpt.c +3
-2ret =_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
Thanks for help and suggestion.
I am looking 'Documentation/SubmittingPatches'.
Thanks
-Arvind Yadav
Quoted 33 lines · Thomas Gleixner
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/SubmittingPatchessays: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.
drivers/clocksource/timer-imx-gpt.c static int __init mxc_timer_init_dt(struct device_node *np, enum imx_gpt_type t · line 515
Quoted 6 lines
ret = _mxc_timer_init(imxtm);drivers/clocksource/timer-imx-gpt.c +3
-2-if (ret) -return ret; +if (ret) { + goto error_iounmap; + }Further
Documentation/SubmittingPatchesalso 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