Skip to contentSkip to conversation

pwm: ep93xx: Fix uninitialized variable bug in ep93xx_pwm_apply()

PATCH In review Dan Carpenter 2 participants 3 messages Jun 30, 2021 – Jul 5, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pwm: ep93xx: Fix uninitialized variable bug in ep93xx_pwm_apply()

Smatch found a potential uninitialized variable in ep93xx_pwm_apply():

drivers/pwm/pwm-ep93xx.c:147 ep93xx_pwm_apply()
error: uninitialized symbol 'ret'.

Initialize "ret" to zero at the start to solve this issue.

Fixes f6ef94edf0f6 ("pwm: ep93xx: Unfold legacy callbacks into ep93xx_pwm_apply()")
---
 drivers/pwm/pwm-ep93xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/pwm-ep93xx.c +1 -1
index 70fa2957f9d3..ffa79248c1e1 100644
@@ -61,7 +61,7 @@ static void ep93xx_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
 static int ep93xx_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 			    const struct pwm_state *state)
 {
-	int ret;
+	int ret = 0;
 	struct ep93xx_pwm *ep93xx_pwm = to_ep93xx_pwm(chip);
 	bool enabled = state->enabled;
 
Signature · 1 line
2.30.2
#2 lore raw

Hello,

Quoted 5 lines · Uwe Kleine-König

this problem was found already earlier by Colin King:

	https://lore.kernel.org/r/[email protected]

I'm fine with either change.

FTR: Thierry applied Colin's patch, so I'm discarding this one from patchwork as not applicable.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |