Skip to contentSkip to conversation

ARM: omap2+: hwmod: fix potential NULL pointer access

PATCH In review Kevin Hilman 2 participants 2 messages Jul 20, 2021 – Jul 27, 2021

Subsystems (4)
lore
Share & tools
lore

Kevin Hilman

author maintainer
#0 lore raw

PATCH 1/1 ARM: omap2+: hwmod: fix potential NULL pointer access

From: Tero Kristo <[email protected]>

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.

---
 arch/arm/mach-omap2/omap_hwmod.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
arch/arm/mach-omap2/omap_hwmod.c +9 -1
index 65934b2924fb..12b26e04686f 100644
@@ -3776,6 +3776,7 @@ struct powerdomain *omap_hwmod_get_pwrdm(struct omap_hwmod *oh)
 	struct omap_hwmod_ocp_if *oi;
 	struct clockdomain *clkdm;
 	struct clk_hw_omap *clk;
+	struct clk_hw *hw;
 
 	if (!oh)
 		return NULL;
@@ -3792,7 +3793,14 @@ struct powerdomain *omap_hwmod_get_pwrdm(struct omap_hwmod *oh)
 		c = oi->_clk;
 	}
 
-	clk = to_clk_hw_omap(__clk_get_hw(c));
+	hw = __clk_get_hw(c);
+	if (!hw)
+		return NULL;
+
+	clk = to_clk_hw_omap(hw);
+	if (!clk)
+		return NULL;
+
 	clkdm = clk->clkdm;
 	if (!clkdm)
 		return NULL;
Signature · 1 line
2.31.1
maintainer
#1 lore raw
Quoted 4 lines · Kevin Hilman

From: Tero Kristo <[email protected]>

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.

Applying into fixes thanks.

Tony