Skip to contentSkip to conversation

iio:addac:ad74413r: Fix uninitialized ret in a path that won't be hit.

PATCH Applied Jonathan Cameron 2 participants 3 messages Dec 20, 2021 – Dec 21, 2021

Subsystems (3)
lore
Share & tools
lore

Jonathan Cameron

author maintainer
#0 lore raw

PATCH 1/1 iio:addac:ad74413r: Fix uninitialized ret in a path that won't be hit.

From: Jonathan Cameron <[email protected]>

I don't believe it's possible to hit this, because we drop out of __iio_update_buffers() earlier in the event of an empty list. However, that is not visible to the compiler so lets return an error if we do hit the loop with an empty bitmask.

Fixes 5d97d9e9a703 ("iio: addac: ad74413r: fix off by one in ad74413r_parse_channel_config()")
Cc Cosmin Tanislav <[email protected]>
---
 drivers/iio/addac/ad74413r.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/addac/ad74413r.c +1 -1
index 289d254943e1..5271073bb74e 100644
@@ -843,7 +843,7 @@ static int ad74413r_update_scan_mode(struct iio_dev *indio_dev,
 	u8 *rx_buf = &st->adc_samples_buf.rx_buf[-1 * AD74413R_FRAME_SIZE];
 	u8 *tx_buf = st->adc_samples_tx_buf;
 	unsigned int channel;
-	int ret;
+	int ret = -EINVAL;
 
 	mutex_lock(&st->lock);
 
Signature · 1 line
2.34.1
author maintainer Applied
#1 lore raw
Quoted 10 lines · On Mon, 20 Dec 2021 16:47:26 +0000 Jonathan Cameron <[email protected]> wrote:

From: Jonathan Cameron <[email protected]>

I don't believe it's possible to hit this, because we drop out of __iio_update_buffers() earlier in the event of an empty list. However, that is not visible to the compiler so lets return an error if we do hit the loop with an empty bitmask.

Fixes 5d97d9e9a703 ("iio: addac: ad74413r: fix off by one in ad74413r_parse_channel_config()")
Cc Cosmin Tanislav <[email protected]>

Given this is 'hopefully' entirely safe and I'd like to get a pull request out later in the week I'm going to apply this immediately.

Note I'd have just fixed it up in the original patch normally but for some reason didn't see the warning until the tree was in a non rebasing state + we have some other fixes in there for this driver.

Applied to the togreg branch of iio.git. Pushed out directly rather than normal testing. I'll sneak a rebase in if anyone gives me a tag before I apply much on top of it.

Thanks,

Jonathan

Quoted 17 lines
---
 drivers/iio/addac/ad74413r.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/addac/ad74413r.c +1 -1
index 289d254943e1..5271073bb74e 100644
@@ -843,7 +843,7 @@ static int ad74413r_update_scan_mode(struct iio_dev *indio_dev,
 	u8 *rx_buf = &st->adc_samples_buf.rx_buf[-1 * AD74413R_FRAME_SIZE];
 	u8 *tx_buf = st->adc_samples_tx_buf;
 	unsigned int channel;
-	int ret;
+	int ret = -EINVAL;
 
 	mutex_lock(&st->lock);
 
Reviewed-by on v1 1/1
#2 lore raw
In reply to Jonathan Cameron
Quoted 19 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

I don't believe it's possible to hit this, because we drop out of __iio_update_buffers() earlier in the event of an empty list. However, that is not visible to the compiler so lets return an error if we do hit the loop with an empty bitmask.

Fixes 5d97d9e9a703 ("iio: addac: ad74413r: fix off by one in ad74413r_parse_channel_config()")
Cc Cosmin Tanislav <[email protected]>
---
 drivers/iio/addac/ad74413r.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/addac/ad74413r.c +0 -0
index 289d254943e1..5271073bb74e 100644

drivers/iio/addac/ad74413r.c static int ad74413r_update_scan_mode(struct iio_dev *indio_dev, · line 846

Quoted 5 lines
drivers/iio/addac/ad74413r.c +1 -1
@@ -843,7 +843,7 @@ static int ad74413r_update_scan_mode(struct iio_dev *indio_dev,
 	u8 *rx_buf = &st->adc_samples_buf.rx_buf[-1 * AD74413R_FRAME_SIZE];
 	u8 *tx_buf = st->adc_samples_tx_buf;
 	unsigned int channel;
-	int ret;
+	int ret = -EINVAL;
Quoted 6 lines
drivers/iio/addac/ad74413r.c +0 -0
 	mutex_lock(&st->lock);
 
Signature · 1 line
2.34.1