Skip to contentSkip to conversation

iio: dac: ad5593r: prevent use of uninitialized variable

PATCH In review Nuno Sá 2 participants 2 messages Sep 16, 2022 – Sep 17, 2022

Subsystems (2)
lore
Share & tools
lore

Nuno Sá

author maintainer
#0 lore raw

PATCH 1/1 iio: dac: ad5593r: prevent use of uninitialized variable

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

Fixes 53b6e3b2164c ("iio: dac: ad5593r: Fix i2c read protocol requirements")
---
 drivers/iio/dac/ad5593r.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/dac/ad5593r.c +3 -1
index bb5e3fe90e89..420981e7c5c3 100644
@@ -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 = {
Signature · 1 line
2.37.3
maintainer
#1 lore raw
Quoted 6 lines · On Fri, 16 Sep 2022 11:33:07 +0200 Nuno Sá <[email protected]> wrote:

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

Fixes 53b6e3b2164c ("iio: dac: ad5593r: Fix i2c read protocol requirements")

That's not a stable commit ID.

Normally I mostly try and keep these stable even before pushing out as non rebasing / togreg. This time around I want to fast forward the tree after the current pull request merges because I need some dependencies that are in char-misc-next for other patches.

I didn't think this through when I said I preferred a separate patch. Anyhow, I've squashed this with the original patch.

Thanks,

Jonathan

Quoted 23 lines
---
 drivers/iio/dac/ad5593r.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/dac/ad5593r.c +3 -1
index bb5e3fe90e89..420981e7c5c3 100644
@@ -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 = {