* [PATCH] ARM: omap2+: hwmod: fix potential NULL pointer access
@ 2021-07-20 18:47 Kevin Hilman
2021-07-27 8:06 ` Tony Lindgren
0 siblings, 1 reply; 2+ messages in thread
From: Kevin Hilman @ 2021-07-20 18:47 UTC (permalink / raw)
To: linux-omap, Tony Lindgren; +Cc: Tero Kristo
From: Tero Kristo <t-kristo@ti.com>
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 <dmurphy@ti.com>
Signed-off-by: Tero Kristo <t-kristo@ti.com>
Cc: stable@vger.kernel.org # v5.10+
Signed-off-by: Kevin Hilman <khilman@baylibre.com>
---
arch/arm/mach-omap2/omap_hwmod.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 65934b2924fb..12b26e04686f 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -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;
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ARM: omap2+: hwmod: fix potential NULL pointer access
2021-07-20 18:47 [PATCH] ARM: omap2+: hwmod: fix potential NULL pointer access Kevin Hilman
@ 2021-07-27 8:06 ` Tony Lindgren
0 siblings, 0 replies; 2+ messages in thread
From: Tony Lindgren @ 2021-07-27 8:06 UTC (permalink / raw)
To: Kevin Hilman; +Cc: linux-omap, Tero Kristo
* Kevin Hilman <khilman@baylibre.com> [210720 21:47]:
> From: Tero Kristo <t-kristo@ti.com>
>
> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-27 8:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-20 18:47 [PATCH] ARM: omap2+: hwmod: fix potential NULL pointer access Kevin Hilman
2021-07-27 8:06 ` Tony Lindgren
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.