Skip to content

Commit

Permalink
pwm: stm32-lp: Add check for clk_enable()
Browse files Browse the repository at this point in the history
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 <zmw12306@gmail.com>
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
Link: https://lore.kernel.org/r/20241206215318.3402860-1-zmw12306@gmail.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
  • Loading branch information
Mingwei Zheng authored and Uwe Kleine-König committed Dec 18, 2024
1 parent 4ccf7e3 commit cce16e7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/pwm/pwm-stm32-lp.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,12 @@ static int stm32_pwm_lp_get_state(struct pwm_chip *chip,
regmap_read(priv->regmap, STM32_LPTIM_CR, &val);
state->enabled = !!FIELD_GET(STM32_LPTIM_ENABLE, val);
/* Keep PWM counter clock refcount in sync with PWM initial state */
if (state->enabled)
clk_enable(priv->clk);
if (state->enabled) {
int ret = clk_enable(priv->clk);

if (ret)
return ret;
}

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

0 comments on commit cce16e7

Please sign in to comment.