* [PATCH V2] pwm: stm32-lp: Add check for clk_enable()
@ 2024-12-06 1:26 Mingwei Zheng
2024-12-06 7:12 ` Uwe Kleine-König
0 siblings, 1 reply; 3+ messages in thread
From: Mingwei Zheng @ 2024-12-06 1:26 UTC (permalink / raw)
To: fabrice.gasnier, ukleinek, mcoquelin.stm32, alexandre.torgue,
hierry.reding, lee
Cc: linux-pwm, linux-stm32, linux-arm-kernel, linux-kernel,
Mingwei Zheng, Jiasheng Jiang
Add check for the return value of clk_enable() to catch the potential
error.
Fixes: e70a540b4e02 ("pwm: Add STM32 LPTimer PWM driver")
Signed-off-by: Mingwei Zheng <zmw12306@gmail.com>
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
---
Changelog:
v1 -> v2
1. Move int ret declaration into if block.
---
drivers/pwm/pwm-stm32-lp.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/pwm/pwm-stm32-lp.c b/drivers/pwm/pwm-stm32-lp.c
index 989731256f50..f09d097d6284 100644
--- a/drivers/pwm/pwm-stm32-lp.c
+++ b/drivers/pwm/pwm-stm32-lp.c
@@ -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);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH V2] pwm: stm32-lp: Add check for clk_enable()
2024-12-06 1:26 [PATCH V2] pwm: stm32-lp: Add check for clk_enable() Mingwei Zheng
@ 2024-12-06 7:12 ` Uwe Kleine-König
2024-12-06 16:53 ` Uwe Kleine-König
0 siblings, 1 reply; 3+ messages in thread
From: Uwe Kleine-König @ 2024-12-06 7:12 UTC (permalink / raw)
To: Mingwei Zheng
Cc: fabrice.gasnier, mcoquelin.stm32, alexandre.torgue,
hierry.reding, lee, linux-pwm, linux-stm32, linux-arm-kernel,
linux-kernel, Jiasheng Jiang
[-- Attachment #1: Type: text/plain, Size: 752 bytes --]
On Thu, Dec 05, 2024 at 08:26:05PM -0500, Mingwei Zheng wrote:
> Add check for the return value of clk_enable() to catch the potential
> error.
>
> Fixes: e70a540b4e02 ("pwm: Add STM32 LPTimer PWM driver")
> Signed-off-by: Mingwei Zheng <zmw12306@gmail.com>
> Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
In reply to (implicit) v1 you wrote:
> We detected this through static analysis, instead of actually hit.
Would be nice to mention the tool that actually found it in the commit
log.
Otherwise I'm happy with that change now.
Given the issue is old (the offending commit is in v4.14-rc1), I'd note
send it as a fix before v4.14. I'd send it along however if something
more urgent pops up.
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH V2] pwm: stm32-lp: Add check for clk_enable()
2024-12-06 7:12 ` Uwe Kleine-König
@ 2024-12-06 16:53 ` Uwe Kleine-König
0 siblings, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2024-12-06 16:53 UTC (permalink / raw)
To: Mingwei Zheng
Cc: fabrice.gasnier, mcoquelin.stm32, alexandre.torgue,
hierry.reding, lee, linux-pwm, linux-stm32, linux-arm-kernel,
linux-kernel, Jiasheng Jiang
[-- Attachment #1: Type: text/plain, Size: 1097 bytes --]
On Fri, Dec 06, 2024 at 08:12:57AM +0100, Uwe Kleine-König wrote:
> On Thu, Dec 05, 2024 at 08:26:05PM -0500, Mingwei Zheng wrote:
> > Add check for the return value of clk_enable() to catch the potential
> > error.
> >
> > Fixes: e70a540b4e02 ("pwm: Add STM32 LPTimer PWM driver")
> > Signed-off-by: Mingwei Zheng <zmw12306@gmail.com>
> > Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
>
> In reply to (implicit) v1 you wrote:
> > We detected this through static analysis, instead of actually hit.
>
> Would be nice to mention the tool that actually found it in the commit
> log.
>
> Otherwise I'm happy with that change now.
>
> Given the issue is old (the offending commit is in v4.14-rc1), I'd note
> send it as a fix before v4.14. I'd send it along however if something
> more urgent pops up.
I wasn't very attentive when I wrote that mail, what I meant was:
Given the issue is old (the offending commit is in v4.14-rc1), I'd not
send it as a fix before v6.13. I'd send it along however if something
more urgent pops up.
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-06 16:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-06 1:26 [PATCH V2] pwm: stm32-lp: Add check for clk_enable() Mingwei Zheng
2024-12-06 7:12 ` Uwe Kleine-König
2024-12-06 16:53 ` Uwe Kleine-König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®