Skip to content

Commit b070f9c

Browse files
Tero Kristotmlind
authored andcommitted
ARM: omap2+: hwmod: fix potential NULL pointer access
omap_hwmod_get_pwrdm() may access a NULL clk_hw pointer in some failure cases. Add a check for the case and bail out gracely if this happens. Reported-by: Dan Murphy <[email protected]> Signed-off-by: Tero Kristo <[email protected]> Cc: [email protected] # v5.10+ Signed-off-by: Kevin Hilman <[email protected]> Signed-off-by: Tony Lindgren <[email protected]>
1 parent e73f0f0 commit b070f9c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

arch/arm/mach-omap2/omap_hwmod.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3776,6 +3776,7 @@ struct powerdomain *omap_hwmod_get_pwrdm(struct omap_hwmod *oh)
37763776
struct omap_hwmod_ocp_if *oi;
37773777
struct clockdomain *clkdm;
37783778
struct clk_hw_omap *clk;
3779+
struct clk_hw *hw;
37793780

37803781
if (!oh)
37813782
return NULL;
@@ -3792,7 +3793,14 @@ struct powerdomain *omap_hwmod_get_pwrdm(struct omap_hwmod *oh)
37923793
c = oi->_clk;
37933794
}
37943795

3795-
clk = to_clk_hw_omap(__clk_get_hw(c));
3796+
hw = __clk_get_hw(c);
3797+
if (!hw)
3798+
return NULL;
3799+
3800+
clk = to_clk_hw_omap(hw);
3801+
if (!clk)
3802+
return NULL;
3803+
37963804
clkdm = clk->clkdm;
37973805
if (!clkdm)
37983806
return NULL;

0 commit comments

Comments
 (0)