[PATCH] iio: dac: ad5593r: prevent use of uninitialized variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Properly error check the call to ad5593r_read_word() so that we do not
end up (would be unlikely but possible) touching uninitialized data.

Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Fixes: 53b6e3b2164c ("iio: dac: ad5593r: Fix i2c read protocol requirements")
Signed-off-by: Nuno Sá <nuno.sa@xxxxxxxxxx>
---
 drivers/iio/dac/ad5593r.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/dac/ad5593r.c b/drivers/iio/dac/ad5593r.c
index bb5e3fe90e89..420981e7c5c3 100644
--- a/drivers/iio/dac/ad5593r.c
+++ b/drivers/iio/dac/ad5593r.c
@@ -83,10 +83,12 @@ static int ad5593r_gpio_read(struct ad5592r_state *st, u8 *value)
 	int ret;
 
 	ret = ad5593r_read_word(i2c, AD5593R_MODE_GPIO_READBACK, &val);
+	if (ret)
+		return ret;
 
 	*value = (u8) val;
 
-	return ret;
+	return 0;
 }
 
 static const struct ad5592r_rw_ops ad5593r_rw_ops = {
-- 
2.37.3




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux