linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: iio: fix ad7606_spi regression
@ 2016-05-30 13:50 Arnd Bergmann
  2016-05-30 13:54 ` Geert Uytterhoeven
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2016-05-30 13:50 UTC (permalink / raw)
  To: Lars-Peter Clausen, Greg Kroah-Hartman
  Cc: Arnd Bergmann, Geert Uytterhoeven, Ksenija Stanojevic,
	Michael Hennerich, Jonathan Cameron, Hartmut Knaack,
	Peter Meerwald-Stadler, Ioana Ciornei, Daniel Baluta, linux-iio,
	devel, linux-kernel

As pointed out by Geert Uytterhoeven, the patch was incorrect
and breaks the driver, which was fortunately pointed out by
this gcc warning:

drivers/staging/iio/adc/ad7606_spi.c: In function ‘ad7606_spi_read_block’:
drivers/staging/iio/adc/ad7606_spi.c:34: warning: ‘data’ is used uninitialized in this function

The effect of the patch is that the data is copied into
a random memory location (from the uninitialized pointer)
instead of being byteswapped in place.

This adds the initialization for the 'data' variable back
to restore the original behavior.

Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
Fixes: 87787e5ef727 ("Staging: iio: Fix sparse endian warning")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/staging/iio/adc/ad7606_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/iio/adc/ad7606_spi.c b/drivers/staging/iio/adc/ad7606_spi.c
index 825da0769936..9587fa86dc69 100644
--- a/drivers/staging/iio/adc/ad7606_spi.c
+++ b/drivers/staging/iio/adc/ad7606_spi.c
@@ -21,7 +21,7 @@ static int ad7606_spi_read_block(struct device *dev,
 {
 	struct spi_device *spi = to_spi_device(dev);
 	int i, ret;
-	unsigned short *data;
+	unsigned short *data = buf;
 	__be16 *bdata = buf;
 
 	ret = spi_read(spi, buf, count * 2);
-- 
2.7.0

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

* Re: [PATCH] staging: iio: fix ad7606_spi regression
  2016-05-30 13:50 [PATCH] staging: iio: fix ad7606_spi regression Arnd Bergmann
@ 2016-05-30 13:54 ` Geert Uytterhoeven
  2016-06-11 16:58   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2016-05-30 13:54 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Lars-Peter Clausen, Greg Kroah-Hartman, Ksenija Stanojevic,
	Michael Hennerich, Jonathan Cameron, Hartmut Knaack,
	Peter Meerwald-Stadler, Ioana Ciornei, Daniel Baluta, linux-iio,
	driverdevel, linux-kernel

On Mon, May 30, 2016 at 3:50 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> As pointed out by Geert Uytterhoeven, the patch was incorrect
> and breaks the driver, which was fortunately pointed out by
> this gcc warning:
>
> drivers/staging/iio/adc/ad7606_spi.c: In function ‘ad7606_spi_read_block’:
> drivers/staging/iio/adc/ad7606_spi.c:34: warning: ‘data’ is used uninitialized in this function
>
> The effect of the patch is that the data is copied into
> a random memory location (from the uninitialized pointer)
> instead of being byteswapped in place.
>
> This adds the initialization for the 'data' variable back
> to restore the original behavior.
>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
> Fixes: 87787e5ef727 ("Staging: iio: Fix sparse endian warning")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] staging: iio: fix ad7606_spi regression
  2016-05-30 13:54 ` Geert Uytterhoeven
@ 2016-06-11 16:58   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2016-06-11 16:58 UTC (permalink / raw)
  To: Geert Uytterhoeven, Arnd Bergmann
  Cc: Lars-Peter Clausen, Greg Kroah-Hartman, Ksenija Stanojevic,
	Michael Hennerich, Hartmut Knaack, Peter Meerwald-Stadler,
	Ioana Ciornei, Daniel Baluta, linux-iio, driverdevel,
	linux-kernel

On 30/05/16 14:54, Geert Uytterhoeven wrote:
> On Mon, May 30, 2016 at 3:50 PM, Arnd Bergmann <arnd@arndb.de> wrote:
>> As pointed out by Geert Uytterhoeven, the patch was incorrect
>> and breaks the driver, which was fortunately pointed out by
>> this gcc warning:
>>
>> drivers/staging/iio/adc/ad7606_spi.c: In function ‘ad7606_spi_read_block’:
>> drivers/staging/iio/adc/ad7606_spi.c:34: warning: ‘data’ is used uninitialized in this function
>>
>> The effect of the patch is that the data is copied into
>> a random memory location (from the uninitialized pointer)
>> instead of being byteswapped in place.
>>
>> This adds the initialization for the 'data' variable back
>> to restore the original behavior.
>>
>> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
>> Cc: Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
>> Fixes: 87787e5ef727 ("Staging: iio: Fix sparse endian warning")
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> 
> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Applied to the fixes-togreg branch of iio.git

Thanks,

Jonathan
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds
> 

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

end of thread, other threads:[~2016-06-11 16:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-30 13:50 [PATCH] staging: iio: fix ad7606_spi regression Arnd Bergmann
2016-05-30 13:54 ` Geert Uytterhoeven
2016-06-11 16:58   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).