diff mbox series

pwm: imx: Signedness bug in imx_pwm_get_state()

Message ID 20190109082747.GA5476@kadam
State Accepted
Headers show
Series pwm: imx: Signedness bug in imx_pwm_get_state() | expand

Commit Message

Dan Carpenter Jan. 9, 2019, 8:27 a.m. UTC
"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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/pwm/pwm-imx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Uwe Kleine-König Jan. 10, 2019, 10:18 a.m. UTC | #1
On Wed, Jan 09, 2019 at 11:27:47AM +0300, Dan Carpenter wrote:
> "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")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

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

Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

@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
Thierry Reding Jan. 10, 2019, 11:08 a.m. UTC | #2
On Thu, Jan 10, 2019 at 11:18:18AM +0100, Uwe Kleine-König wrote:
> On Wed, Jan 09, 2019 at 11:27:47AM +0300, Dan Carpenter wrote:
> > "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")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> I would have expected a compiler warning but at least for me there is
> none emitted. Hmm.
> 
> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> 
> @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
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c
index 55a3a363d5be..b8452abe2392 100644
--- a/drivers/pwm/pwm-imx.c
+++ b/drivers/pwm/pwm-imx.c
@@ -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)