Skip to contentSkip to conversation

clk: Unlink clock if failed to prepare or enable

PATCH Applied Marc Zyngier 2 participants 2 messages May 5, 2020 Common clk

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: Unlink clock if failed to prepare or enable

On failing to prepare or enable a clock, remove the core structure from the list it has been inserted as it is about to be freed.

This otherwise leads to random crashes when subsequent clocks get registered, during which parsing of the clock tree becomes adventurous.

Observed with QEMU's RPi-3 emulation.

Fixes 12ead77432f2 ("clk: Don't try to enable critical clocks if prepare failed")
Cc Guenter Roeck <[email protected]>
Cc Stephen Boyd <[email protected]>
Cc Michael Turquette <[email protected]>
---
 drivers/clk/clk.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/clk/clk.c +3 -0
index b34fc1d3a594..752e8eef3f55 100644
@@ -3522,6 +3522,9 @@ static int __clk_core_init(struct clk_core *core)
 out:
 	clk_pm_runtime_put(core);
 unlock:
+	if (ret)
+		hlist_del_init(&core->child_node);
+
 	clk_prepare_unlock();
 
 	if (!ret)
Signature · 1 line
2.20.1
maintainer Applied
#1 lore raw

Quoting Marc Zyngier (2020-05-05 07:09:53)

Quoted 6 lines

On failing to prepare or enable a clock, remove the core structure from the list it has been inserted as it is about to be freed.

This otherwise leads to random crashes when subsequent clocks get registered, during which parsing of the clock tree becomes adventurous.

Quoted 8 lines

Observed with QEMU's RPi-3 emulation.

Fixes 12ead77432f2 ("clk: Don't try to enable critical clocks if prepare failed")
Cc Guenter Roeck <[email protected]>
Cc Stephen Boyd <[email protected]>
Cc Michael Turquette <[email protected]>

---

Applied to clk-fixes