Skip to content

Commit e97fe49

Browse files
0xB0Dbebarino
authored andcommitted
clk: Fix clk_core_get NULL dereference
It is possible for clk_core_get to dereference a NULL in the following sequence: clk_core_get() of_clk_get_hw_from_clkspec() __of_clk_get_hw_from_provider() __clk_get_hw() __clk_get_hw() can return NULL which is dereferenced by clk_core_get() at hw->core. Prior to commit dde4eff ("clk: Look for parents with clkdev based clk_lookups") the check IS_ERR_OR_NULL() was performed which would have caught the NULL. Reading the description of this function it talks about returning NULL but that cannot be so at the moment. Update the function to check for hw before dereferencing it and return NULL if hw is NULL. Fixes: dde4eff ("clk: Look for parents with clkdev based clk_lookups") Signed-off-by: Bryan O'Donoghue <[email protected]> Link: https://lore.kernel.org/r/20240302-linux-next-24-03-01-simple-clock-fixes-v1-1-25f348a5982b@linaro.org Signed-off-by: Stephen Boyd <[email protected]>
1 parent 6613476 commit e97fe49

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/clk/clk.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ static struct clk_core *clk_core_get(struct clk_core *core, u8 p_index)
418418
if (IS_ERR(hw))
419419
return ERR_CAST(hw);
420420

421+
if (!hw)
422+
return NULL;
423+
421424
return hw->core;
422425
}
423426

0 commit comments

Comments
 (0)