Skip to contentSkip to conversation

pwm: imx: Signedness bug in imx_pwm_get_state()

PATCH In review Dan Carpenter 3 participants 3 messages Jan 9, 2019 – Jan 10, 2019

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

PATCH 1/1 pwm: imx: Signedness bug in imx_pwm_get_state()

"ret" only holds zero and negative error codes. It needs to be signed for the error handling to work.

Fixes 9f4c8f9607c3 ("pwm: imx: Add ipg clock operation")
---
 drivers/pwm/pwm-imx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pwm/pwm-imx.c +2 -1
index 55a3a363d5be..b8452abe2392 100644
@@ -128,8 +128,9 @@ static void imx_pwm_get_state(struct pwm_chip *chip,
 		struct pwm_device *pwm, struct pwm_state *state)
 {
 	struct imx_chip *imx = to_imx_chip(chip);
-	u32 period, prescaler, pwm_clk, ret, val;
+	u32 period, prescaler, pwm_clk, val;
 	u64 tmp;
+	int ret;
 
 	ret = imx_pwm_clk_prepare_enable(chip);
 	if (ret < 0)
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Dan Carpenter

"ret" only holds zero and negative error codes. It needs to be signed for the error handling to work.

Fixes 9f4c8f9607c3 ("pwm: imx: Add ipg clock operation")

I would have expected a compiler warning but at least for me there is none emitted. Hmm.

@Thierry: Given that this is a fix I assume you want to apply this patch before my pwm-imx series (which is cleanup only). This will conflict for sure with my driver splitting patch. Please tell me if/when I should resend my series rebased on top of this patch.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#2 lore raw
In reply to Dan Carpenter
Quoted 10 lines · Uwe Kleine-König
Quoted 5 lines · Dan Carpenter

"ret" only holds zero and negative error codes. It needs to be signed for the error handling to work.

Fixes 9f4c8f9607c3 ("pwm: imx: Add ipg clock operation")

I would have expected a compiler warning but at least for me there is none emitted. Hmm.

Quoted 6 lines

@Thierry: Given that this is a fix I assume you want to apply this patch before my pwm-imx series (which is cleanup only). This will conflict for sure with my driver splitting patch. Please tell me if/when I should resend my series rebased on top of this patch.

It's fine, I manually applied this on top of the driver split patch.

Thierry