clk/ingenic: fix clock leak on clk_register_clkdev failure
Subsystems (4)
PATCH v2 1/1 clk/ingenic: fix clock leak on clk_register_clkdev failure
clk_register() succeeds but clk_register_clkdev() fails, and the error path jumps to out without calling clk_unregister or clk_put to release the registered clock. This leaks the clock object within the common clock framework, contrasting with the CGU_CLK_EXT type path which correctly calls clk_put on error.
---
Changes in v2:
- Fix patch format based on reviewer feedback
--- drivers/clk/ingenic/cgu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/ingenic/cgu.c +3 -1
@@ -774,8 +774,10 @@ static int ingenic_register_clock(struct ingenic_cgu *cgu, unsigned idx) } err =clk_register_clkdev (clk, clk_info->name,NULL ); -if (err) +if (err) { +clk_unregister (clk); goto out; + } cgu->clocks.clks[idx] = clk; out:
Signature · 1 line
2.39.5 (Apple Git-154)
Quoted 8 lines · WenTao Liang
clk_register()succeeds butclk_register_clkdev()fails, and the error path jumps to out without callingclk_unregisterorclk_putto release the registered clock. This leaks the clock object within the common clock framework, contrasting with the
CGU_CLK_EXTtype path which correctly callsclk_puton error.
I would drop this part. Just focus on what you are fixing.
Quoted 2 lines
Suggested-by Greg KH <[email protected]>
I don't see where on the v1 Greg suggested this, unless I am missing something?
Quoted 6 lines
Fixes b066303fb3e7 ("clk: ingenic: add driver for Ingenic SoC CGU clocks")Signed-off-by WenTao Liang <[email protected]>---
Changes in v2:
- Fix patch format based on reviewer feedback
Link to v1: https://lore.kernel.org/linux-clk/[email protected]/
With those fixes:
Quoted 23 lines
--- drivers/clk/ingenic/cgu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/clk/ingenic/cgu.c +3
-1@@ -774,8 +774,10 @@ static int ingenic_register_clock(struct ingenic_cgu *cgu, unsigned idx) } err =clk_register_clkdev (clk, clk_info->name,NULL ); -if (err) +if (err) { +clk_unregister (clk); goto out; + } cgu->clocks.clks[idx] = clk; out:Signature · 1 line
2.39.5 (Apple Git-154)
Greg KH
maintainerQuoted 10 lines · Brian Masney
Quoted 8 lines · WenTao Liang
clk_register()succeeds butclk_register_clkdev()fails, and the error path jumps to out without callingclk_unregisterorclk_putto release the registered clock. This leaks the clock object within the common clock framework, contrasting with the
CGU_CLK_EXTtype path which correctly callsclk_puton error.
Quoted 7 lines
I would drop this part. Just focus on what you are fixing.
Quoted 2 lines
Suggested-by Greg KH <[email protected]>I don't see where on the v1 Greg suggested this, unless I am missing something?
I did not.
Quoted 7 lines
Quoted 6 lines
Fixes b066303fb3e7 ("clk: ingenic: add driver for Ingenic SoC CGU clocks")Signed-off-by WenTao Liang <[email protected]>---
Changes in v2:
- Fix patch format based on reviewer feedback
Quoted 5 lines
Link to v1: https://lore.kernel.org/linux-clk/[email protected]/
With those fixes:
Reviewed-by Brian Masney <[email protected]>
All of these need to be dropped until the submitter learns how to properly submit things.
greg k-h