Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: ti: autoidle: add checks against NULL pointer reference

The clk pointer passed to omap2_clk_(deny|allow)_idle can be NULL, so
add checks for this.

Reported-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Tero Kristo <t-kristo@ti.com>
Link: https://lore.kernel.org/r/20200907082600.454-2-t-kristo@ti.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Tero Kristo and committed by
Stephen Boyd
cec4a609 4630ef13

+12 -2
+12 -2
drivers/clk/ti/autoidle.c
··· 82 82 */ 83 83 int omap2_clk_deny_idle(struct clk *clk) 84 84 { 85 - struct clk_hw *hw = __clk_get_hw(clk); 85 + struct clk_hw *hw; 86 + 87 + if (!clk) 88 + return -EINVAL; 89 + 90 + hw = __clk_get_hw(clk); 86 91 87 92 if (omap2_clk_is_hw_omap(hw)) { 88 93 struct clk_hw_omap *c = to_clk_hw_omap(hw); ··· 106 101 */ 107 102 int omap2_clk_allow_idle(struct clk *clk) 108 103 { 109 - struct clk_hw *hw = __clk_get_hw(clk); 104 + struct clk_hw *hw; 105 + 106 + if (!clk) 107 + return -EINVAL; 108 + 109 + hw = __clk_get_hw(clk); 110 110 111 111 if (omap2_clk_is_hw_omap(hw)) { 112 112 struct clk_hw_omap *c = to_clk_hw_omap(hw);