Linux-IIO Archive on lore.kernel.org
 help / Atom feed
* [PATCH] iio: ad9523: fix a missing check of return value
@ 2018-12-20  7:21 Kangjie Lu
  2018-12-22 17:34 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2018-12-20  7:21 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Lars-Peter Clausen, Michael Hennerich,
	Jonathan Cameron, Hartmut Knaack, Peter Meerwald-Stadler,
	linux-iio, linux-kernel

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.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/iio/frequency/ad9523.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
index f3f94fbdd20a..3f9be69499ec 100644
--- a/drivers/iio/frequency/ad9523.c
+++ b/drivers/iio/frequency/ad9523.c
@@ -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)
-- 
2.17.2 (Apple Git-113)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] iio: ad9523: fix a missing check of return value
  2018-12-20  7:21 [PATCH] iio: ad9523: fix a missing check of return value Kangjie Lu
@ 2018-12-22 17:34 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2018-12-22 17:34 UTC (permalink / raw)
  To: Kangjie Lu
  Cc: pakki001, Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, linux-iio, linux-kernel

On Thu, 20 Dec 2018 01:21:22 -0600
Kangjie Lu <kjlu@umn.edu> 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.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/frequency/ad9523.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c
> index f3f94fbdd20a..3f9be69499ec 100644
> --- a/drivers/iio/frequency/ad9523.c
> +++ b/drivers/iio/frequency/ad9523.c
> @@ -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)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-20  7:21 [PATCH] iio: ad9523: fix a missing check of return value Kangjie Lu
2018-12-22 17:34 ` Jonathan Cameron

Linux-IIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iio/0 linux-iio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iio linux-iio/ https://lore.kernel.org/linux-iio \
		linux-iio@vger.kernel.org linux-iio@archiver.kernel.org
	public-inbox-index linux-iio


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-iio


AGPL code for this site: git clone https://public-inbox.org/ public-inbox