summaryrefslogtreecommitdiff
path: root/drivers/pwm/pwm-stm32-lp.c
diff options
context:
space:
mode:
authorMingwei Zheng <zmw12306@gmail.com>2024-12-06 16:53:18 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-21 13:49:01 +0100
commit78564038adab2a2163be591d731f3007c3d5c60c (patch)
treea5308681bd3156551b352e25970fc44b347e2ec8 /drivers/pwm/pwm-stm32-lp.c
parent2d9c5a72a963a2fb12ac9709b58352df326e0b23 (diff)
downloadlinux-78564038adab2a2163be591d731f3007c3d5c60c.tar.gz
linux-78564038adab2a2163be591d731f3007c3d5c60c.tar.bz2
linux-78564038adab2a2163be591d731f3007c3d5c60c.zip
pwm: stm32-lp: Add check for clk_enable()
[ Upstream commit cce16e7f6216227964cda25f5f23634bce2c500f ] Add check for the return value of clk_enable() to catch the potential error. We used APP-Miner to find it. Fixes: e70a540b4e02 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/pwm/pwm-stm32-lp.c')
-rw-r--r--drivers/pwm/pwm-stm32-lp.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/pwm/pwm-stm32-lp.c b/drivers/pwm/pwm-stm32-lp.c
index 31a185c6b8da..7f477082db1d 100644
--- a/drivers/pwm/pwm-stm32-lp.c
+++ b/drivers/pwm/pwm-stm32-lp.c
@@ -169,8 +169,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);