Skip to content

Commit 5c1c42c

Browse files
committed
clk: clk_core_get() can also return NULL
Nothing stops a clk controller from registering an OF clk provider before registering those clks with the clk framework. This is not great but we deal with it in the clk framework by refusing to hand out struct clk pointers when 'hw->core' is NULL, the indication that clk_register() has been called. Within clk_core_fill_parent_index() we considered this case when a clk_hw pointer is referenced directly by filling in the parent cache with an -EPROBE_DEFER pointer when the core pointer is NULL. When we lookup a parent with clk_core_get() we don't care about the return value being NULL though, because that was considered largely impossible, but it's been proven now that it can be NULL if two clk providers are probing in parallel and the parent provider has been registered before the clk has. Let's check for NULL here as well and treat it the same as direct clk_hw references. Signed-off-by: Stephen Boyd <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9259228 commit 5c1c42c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

drivers/clk/clk.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -424,19 +424,20 @@ static void clk_core_fill_parent_index(struct clk_core *core, u8 index)
424424

425425
if (entry->hw) {
426426
parent = entry->hw->core;
427-
/*
428-
* We have a direct reference but it isn't registered yet?
429-
* Orphan it and let clk_reparent() update the orphan status
430-
* when the parent is registered.
431-
*/
432-
if (!parent)
433-
parent = ERR_PTR(-EPROBE_DEFER);
434427
} else {
435428
parent = clk_core_get(core, index);
436429
if (PTR_ERR(parent) == -ENOENT && entry->name)
437430
parent = clk_core_lookup(entry->name);
438431
}
439432

433+
/*
434+
* We have a direct reference but it isn't registered yet?
435+
* Orphan it and let clk_reparent() update the orphan status
436+
* when the parent is registered.
437+
*/
438+
if (!parent)
439+
parent = ERR_PTR(-EPROBE_DEFER);
440+
440441
/* Only cache it if it's not an error */
441442
if (!IS_ERR(parent))
442443
entry->core = parent;

0 commit comments

Comments
 (0)