Commit b070f9ca authored by Tero Kristo's avatar Tero Kristo Committed by Tony Lindgren
Browse files

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: default avatarDan Murphy <dmurphy@ti.com>
Signed-off-by: default avatarTero Kristo <t-kristo@ti.com>
Cc: stable@vger.kernel.org # v5.10+
Signed-off-by: default avatarKevin Hilman <khilman@baylibre.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent e73f0f0e
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -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;