Skip to contentSkip to conversation

mtd: rawnand: nuvoton: fix clock cleanup on probe failure

PATCH Applied Guangshuo Li 2 participants 2 messages Sep 15 – Sep 25

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: rawnand: nuvoton: fix clock cleanup on probe failure

ma35_nand_probe() gets and enables the NAND clock with devm_clk_get_enabled(), but the ma35_nand_chips_init() failure path also calls clk_disable() before returning.

devm_clk_get_enabled() registers a managed cleanup that calls clk_disable_unprepare() on probe failure and driver removal. Calling clk_disable() explicitly first drops the clock enable count, so the managed cleanup attempts to disable the clock again and triggers the clock framework warning for an already disabled clock.

Remove the redundant clk_disable() and let the managed clock cleanup handle the clock state.

This issue was found by manual code inspection.

Fixes 5abb5d414d55 ("mtd: rawnand: nuvoton: add new driver for the Nuvoton MA35 SoC")
---
 drivers/mtd/nand/raw/nuvoton-ma35d1-nand-controller.c | 1 -
 1 file changed, 1 deletion(-)
drivers/mtd/nand/raw/nuvoton-ma35d1-nand-controller.c +0 -1
index 1a285cd8fad6..f659d3a6b9ef 100644
@@ -993,7 +993,6 @@ static int ma35_nand_probe(struct platform_device *pdev)
 	ret = ma35_nand_chips_init(&pdev->dev, nand);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to init NAND chips\n");
-		clk_disable(nand->clk);
 		return ret;
 	}
 
Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 11 lines · Guangshuo Li

ma35_nand_probe() gets and enables the NAND clock with devm_clk_get_enabled(), but the ma35_nand_chips_init() failure path also calls clk_disable() before returning.

devm_clk_get_enabled() registers a managed cleanup that calls clk_disable_unprepare() on probe failure and driver removal. Calling clk_disable() explicitly first drops the clock enable count, so the managed cleanup attempts to disable the clock again and triggers the clock framework warning for an already disabled clock.

[...]

Applied to nand/next, thanks!

[1/1] mtd: rawnand: nuvoton: fix clock cleanup on probe failure

      commit: 8a485a40f45a19c5fcafb5cbee7387c2762af7c4

Patche(s) should be available on mtd/linux.git and will be part of the next PR (provided that no robot complains by then).

Kind regards,
Miquèl