linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: Unlink clock if failed to prepare or enable
@ 2020-05-05 14:09 Marc Zyngier
  2020-05-05 19:12 ` Stephen Boyd
  0 siblings, 1 reply; 2+ messages in thread
From: Marc Zyngier @ 2020-05-05 14:09 UTC (permalink / raw)
  To: linux-clk, linux-kernel; +Cc: Guenter Roeck, Stephen Boyd, Michael Turquette

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")
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Michael Turquette <mturquette@baylibre.com>
---
 drivers/clk/clk.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index b34fc1d3a594..752e8eef3f55 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -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)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] clk: Unlink clock if failed to prepare or enable
  2020-05-05 14:09 [PATCH] clk: Unlink clock if failed to prepare or enable Marc Zyngier
@ 2020-05-05 19:12 ` Stephen Boyd
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2020-05-05 19:12 UTC (permalink / raw)
  To: Marc Zyngier, linux-clk, linux-kernel; +Cc: Guenter Roeck, Michael Turquette

Quoting Marc Zyngier (2020-05-05 07:09:53)
> 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")
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Stephen Boyd <sboyd@kernel.org>
> Cc: Michael Turquette <mturquette@baylibre.com>
> ---

Applied to clk-fixes

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-05 19:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05 14:09 [PATCH] clk: Unlink clock if failed to prepare or enable Marc Zyngier
2020-05-05 19:12 ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).