blob: 9432ff28b5d76f62f7d924c1165b4eed40d0d8df [file] [log] [blame]
From 5aa3f60d2e649df16c369c7e623ca2978d84724e Mon Sep 17 00:00:00 2001
From: Marc Zyngier <>
Date: Tue, 5 May 2020 15:09:53 +0100
Subject: [PATCH] clk: Unlink clock if failed to prepare or enable
commit 018d4671b9bbd4a5c55cf6eab3e1dbc70a50b66e upstream.
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 <>
Cc: Guenter Roeck <>
Cc: Stephen Boyd <>
Cc: Michael Turquette <>
Signed-off-by: Stephen Boyd <>
Signed-off-by: Paul Gortmaker <>
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 37f1584e12c3..0ae52b9309e8 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3388,6 +3388,9 @@ static int __clk_core_init(struct clk_core *core)
+ if (ret)
+ hlist_del_init(&core->child_node);
if (!ret)