Skip to content

Commit cce16e7

Browse files
zmw12306Uwe Kleine-König
authored andcommitted
pwm: stm32-lp: Add check for clk_enable()
Add check for the return value of clk_enable() to catch the potential error. We used APP-Miner to find it. Fixes: e70a540 ("pwm: Add STM32 LPTimer PWM driver") Signed-off-by: Mingwei Zheng <[email protected]> Signed-off-by: Jiasheng Jiang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Uwe Kleine-König <[email protected]>
1 parent 4ccf7e3 commit cce16e7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/pwm/pwm-stm32-lp.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,12 @@ static int stm32_pwm_lp_get_state(struct pwm_chip *chip,
167167
regmap_read(priv->regmap, STM32_LPTIM_CR, &val);
168168
state->enabled = !!FIELD_GET(STM32_LPTIM_ENABLE, val);
169169
/* Keep PWM counter clock refcount in sync with PWM initial state */
170-
if (state->enabled)
171-
clk_enable(priv->clk);
170+
if (state->enabled) {
171+
int ret = clk_enable(priv->clk);
172+
173+
if (ret)
174+
return ret;
175+
}
172176

173177
regmap_read(priv->regmap, STM32_LPTIM_CFGR, &val);
174178
presc = FIELD_GET(STM32_LPTIM_PRESC, val);

0 commit comments

Comments
 (0)