All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: dac: ad5593r: prevent use of uninitialized variable
@ 2022-09-16  9:33 Nuno Sá
  2022-09-17 13:38 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Nuno Sá @ 2022-09-16  9:33 UTC (permalink / raw)
  To: linux-iio
  Cc: Lars-Peter Clausen, Jonathan Cameron, Michael Hennerich,
	kernel test robot, Dan Carpenter

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@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 53b6e3b2164c ("iio: dac: ad5593r: Fix i2c read protocol requirements")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 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


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

* Re: [PATCH] iio: dac: ad5593r: prevent use of uninitialized variable
  2022-09-16  9:33 [PATCH] iio: dac: ad5593r: prevent use of uninitialized variable Nuno Sá
@ 2022-09-17 13:38 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2022-09-17 13:38 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-iio, Lars-Peter Clausen, Michael Hennerich,
	kernel test robot, Dan Carpenter

On Fri, 16 Sep 2022 11:33:07 +0200
Nuno Sá <nuno.sa@analog.com> 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.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> 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


> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  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 = {


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

end of thread, other threads:[~2022-09-17 13:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16  9:33 [PATCH] iio: dac: ad5593r: prevent use of uninitialized variable Nuno Sá
2022-09-17 13:38 ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.