Skip to contentSkip to conversation

iio: ad9523: fix a missing check of return value

PATCH In review Kangjie Lu 2 participants 2 messages Dec 20, 2018 – Dec 22, 2018

Subsystems (2)
lore
Share & tools
lore

Kangjie Lu

author
#0 lore raw

PATCH 1/1 iio: ad9523: fix a missing check of return value

If ad9523_write() fails, indio_dev may get incorrect data. The fix inserts a check for the return value of ad9523_write(), and it fails, returns an error.

---
 drivers/iio/frequency/ad9523.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iio/frequency/ad9523.c +5 -2
index f3f94fbdd20a..3f9be69499ec 100644
@@ -943,11 +943,14 @@ static int ad9523_setup(struct iio_dev *indio_dev)
 		}
 	}
 
-	for_each_clear_bit(i, &active_mask, AD9523_NUM_CHAN)
-		ad9523_write(indio_dev,
+	for_each_clear_bit(i, &active_mask, AD9523_NUM_CHAN) {
+		ret = ad9523_write(indio_dev,
 			     AD9523_CHANNEL_CLOCK_DIST(i),
 			     AD9523_CLK_DIST_DRIVER_MODE(TRISTATE) |
 			     AD9523_CLK_DIST_PWR_DOWN_EN);
+		if (ret < 0)
+			return ret;
+	}
 
 	ret = ad9523_write(indio_dev, AD9523_POWER_DOWN_CTRL, 0);
 	if (ret < 0)
Signature · 1 line
2.17.2 (Apple Git-113)
maintainer
#1 lore raw
Quoted 5 lines · On Thu, 20 Dec 2018 01:21:22 -0600 Kangjie Lu <[email protected]> wrote:

If ad9523_write() fails, indio_dev may get incorrect data. The fix inserts a check for the return value of ad9523_write(), and it fails, returns an error.

Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.

Thanks,

Jonathan

Quoted 25 lines
---
 drivers/iio/frequency/ad9523.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iio/frequency/ad9523.c +5 -2
index f3f94fbdd20a..3f9be69499ec 100644
@@ -943,11 +943,14 @@ static int ad9523_setup(struct iio_dev *indio_dev)
 		}
 	}
 
-	for_each_clear_bit(i, &active_mask, AD9523_NUM_CHAN)
-		ad9523_write(indio_dev,
+	for_each_clear_bit(i, &active_mask, AD9523_NUM_CHAN) {
+		ret = ad9523_write(indio_dev,
 			     AD9523_CHANNEL_CLOCK_DIST(i),
 			     AD9523_CLK_DIST_DRIVER_MODE(TRISTATE) |
 			     AD9523_CLK_DIST_PWR_DOWN_EN);
+		if (ret < 0)
+			return ret;
+	}
 
 	ret = ad9523_write(indio_dev, AD9523_POWER_DOWN_CTRL, 0);
 	if (ret < 0)