linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: adc: gyroadc: fix uninitialized return code
@ 2019-07-04 11:37 Arnd Bergmann
  2019-07-04 11:49 ` Geert Uytterhoeven
  2019-07-04 12:07 ` Wolfram Sang
  0 siblings, 2 replies; 7+ messages in thread
From: Arnd Bergmann @ 2019-07-04 11:37 UTC (permalink / raw)
  To: Marek Vasut, Jonathan Cameron
  Cc: Arnd Bergmann, stable, Marek Vasut, Geert Uytterhoeven,
	Simon Horman, linux-renesas-soc, Wolfram Sang, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Kuninori Morimoto, linux-iio, linux-kernel

gcc-9 complains about a blatant uninitialized variable use that
all earlier compiler versions missed:

drivers/iio/adc/rcar-gyroadc.c:510:5: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]

Return -EINVAL instead here.

Cc: stable@vger.kernel.org
Fixes: 059c53b32329 ("iio: adc: Add Renesas GyroADC driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/iio/adc/rcar-gyroadc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c
index 2d685730f867..aec73cc43e23 100644
--- a/drivers/iio/adc/rcar-gyroadc.c
+++ b/drivers/iio/adc/rcar-gyroadc.c
@@ -391,7 +391,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev)
 			dev_err(dev,
 				"Channel %i uses different ADC mode than the rest.\n",
 				reg);
-			return ret;
+			return -EINVAL;
 		}
 
 		/* Channel is valid, grab the regulator. */
-- 
2.20.0


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

* Re: [PATCH] iio: adc: gyroadc: fix uninitialized return code
  2019-07-04 11:37 [PATCH] iio: adc: gyroadc: fix uninitialized return code Arnd Bergmann
@ 2019-07-04 11:49 ` Geert Uytterhoeven
  2019-07-04 12:07 ` Wolfram Sang
  1 sibling, 0 replies; 7+ messages in thread
From: Geert Uytterhoeven @ 2019-07-04 11:49 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Marek Vasut, Jonathan Cameron, stable, Marek Vasut,
	Geert Uytterhoeven, Simon Horman, Linux-Renesas, Wolfram Sang,
	Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Kuninori Morimoto, linux-iio,
	Linux Kernel Mailing List

Hi Arnd,

On Thu, Jul 4, 2019 at 1:38 PM Arnd Bergmann <arnd@arndb.de> wrote:
> gcc-9 complains about a blatant uninitialized variable use that
> all earlier compiler versions missed:
>
> drivers/iio/adc/rcar-gyroadc.c:510:5: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]

Actually gcc-4.1 warned about that one too ;-)

So either I must have missed that warning when it appeared first,
or I must have concluded wrongly that it was a false positive.
Sorry for that...

> Return -EINVAL instead here.
>
> Cc: stable@vger.kernel.org
> Fixes: 059c53b32329 ("iio: adc: Add Renesas GyroADC driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

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] 7+ messages in thread

* Re: [PATCH] iio: adc: gyroadc: fix uninitialized return code
  2019-07-04 11:37 [PATCH] iio: adc: gyroadc: fix uninitialized return code Arnd Bergmann
  2019-07-04 11:49 ` Geert Uytterhoeven
@ 2019-07-04 12:07 ` Wolfram Sang
  2019-07-04 12:10   ` Geert Uytterhoeven
  1 sibling, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2019-07-04 12:07 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Marek Vasut, Jonathan Cameron, stable, Marek Vasut,
	Geert Uytterhoeven, Simon Horman, linux-renesas-soc,
	Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Kuninori Morimoto, linux-iio, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 728 bytes --]

On Thu, Jul 04, 2019 at 01:37:47PM +0200, Arnd Bergmann wrote:
> gcc-9 complains about a blatant uninitialized variable use that
> all earlier compiler versions missed:
> 
> drivers/iio/adc/rcar-gyroadc.c:510:5: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
> 
> Return -EINVAL instead here.
> 
> Cc: stable@vger.kernel.org
> Fixes: 059c53b32329 ("iio: adc: Add Renesas GyroADC driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

This is correct but missing that the above 'return ret' is broken, too.
ret is initialized but 0 in that case.

And maybe we can use something else than -EINVAL for this case? I am on
the go right now, I will look for a suggestion later.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] iio: adc: gyroadc: fix uninitialized return code
  2019-07-04 12:07 ` Wolfram Sang
@ 2019-07-04 12:10   ` Geert Uytterhoeven
  2019-07-04 15:27     ` Marek Vasut
  0 siblings, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2019-07-04 12:10 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Arnd Bergmann, Marek Vasut, Jonathan Cameron, stable,
	Marek Vasut, Geert Uytterhoeven, Simon Horman, Linux-Renesas,
	Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Kuninori Morimoto, linux-iio,
	Linux Kernel Mailing List

Hi Wolfram,

On Thu, Jul 4, 2019 at 2:08 PM Wolfram Sang <wsa@the-dreams.de> wrote:
> On Thu, Jul 04, 2019 at 01:37:47PM +0200, Arnd Bergmann wrote:
> > gcc-9 complains about a blatant uninitialized variable use that
> > all earlier compiler versions missed:
> >
> > drivers/iio/adc/rcar-gyroadc.c:510:5: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
> >
> > Return -EINVAL instead here.
> >
> > Cc: stable@vger.kernel.org
> > Fixes: 059c53b32329 ("iio: adc: Add Renesas GyroADC driver")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> This is correct but missing that the above 'return ret' is broken, too.
> ret is initialized but 0 in that case.

Nice catch! Oh well, given enough eyeballs, ...

> And maybe we can use something else than -EINVAL for this case? I am on
> the go right now, I will look for a suggestion later.

-EINVAL is correct here (and in the above case, too), IMHO.

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] 7+ messages in thread

* Re: [PATCH] iio: adc: gyroadc: fix uninitialized return code
  2019-07-04 12:10   ` Geert Uytterhoeven
@ 2019-07-04 15:27     ` Marek Vasut
  2019-07-04 19:55       ` Wolfram Sang
  0 siblings, 1 reply; 7+ messages in thread
From: Marek Vasut @ 2019-07-04 15:27 UTC (permalink / raw)
  To: Geert Uytterhoeven, Wolfram Sang
  Cc: Arnd Bergmann, Jonathan Cameron, stable, Marek Vasut,
	Geert Uytterhoeven, Simon Horman, Linux-Renesas, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler, Rob Herring,
	Kuninori Morimoto, linux-iio, Linux Kernel Mailing List

On 7/4/19 2:10 PM, Geert Uytterhoeven wrote:
> Hi Wolfram,
> 
> On Thu, Jul 4, 2019 at 2:08 PM Wolfram Sang <wsa@the-dreams.de> wrote:
>> On Thu, Jul 04, 2019 at 01:37:47PM +0200, Arnd Bergmann wrote:
>>> gcc-9 complains about a blatant uninitialized variable use that
>>> all earlier compiler versions missed:
>>>
>>> drivers/iio/adc/rcar-gyroadc.c:510:5: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
>>>
>>> Return -EINVAL instead here.
>>>
>>> Cc: stable@vger.kernel.org
>>> Fixes: 059c53b32329 ("iio: adc: Add Renesas GyroADC driver")
>>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>>
>> This is correct but missing that the above 'return ret' is broken, too.
>> ret is initialized but 0 in that case.
> 
> Nice catch! Oh well, given enough eyeballs, ...

I don't think ret is initialized, reg is, not ret .

>> And maybe we can use something else than -EINVAL for this case? I am on
>> the go right now, I will look for a suggestion later.
> 
> -EINVAL is correct here (and in the above case, too), IMHO.

Yep, -EINVAL is fine.

-- 
Best regards,
Marek Vasut

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

* Re: [PATCH] iio: adc: gyroadc: fix uninitialized return code
  2019-07-04 15:27     ` Marek Vasut
@ 2019-07-04 19:55       ` Wolfram Sang
  2019-07-14 15:09         ` Jonathan Cameron
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfram Sang @ 2019-07-04 19:55 UTC (permalink / raw)
  To: Marek Vasut
  Cc: Geert Uytterhoeven, Arnd Bergmann, Jonathan Cameron, stable,
	Marek Vasut, Geert Uytterhoeven, Simon Horman, Linux-Renesas,
	Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Kuninori Morimoto, linux-iio,
	Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 354 bytes --]


> >> This is correct but missing that the above 'return ret' is broken, too.
> >> ret is initialized but 0 in that case.
> > 
> > Nice catch! Oh well, given enough eyeballs, ...
> 
> I don't think ret is initialized, reg is, not ret .

It is initialized for the broken 'return ret' *above* the one which gets
rightfully fixed in this patch.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] iio: adc: gyroadc: fix uninitialized return code
  2019-07-04 19:55       ` Wolfram Sang
@ 2019-07-14 15:09         ` Jonathan Cameron
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2019-07-14 15:09 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Marek Vasut, Geert Uytterhoeven, Arnd Bergmann, stable,
	Marek Vasut, Geert Uytterhoeven, Simon Horman, Linux-Renesas,
	Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
	Rob Herring, Kuninori Morimoto, linux-iio,
	Linux Kernel Mailing List

On Thu, 4 Jul 2019 21:55:58 +0200
Wolfram Sang <wsa@the-dreams.de> wrote:

> > >> This is correct but missing that the above 'return ret' is broken, too.
> > >> ret is initialized but 0 in that case.  
> > > 
> > > Nice catch! Oh well, given enough eyeballs, ...  
> > 
> > I don't think ret is initialized, reg is, not ret .  
> 
> It is initialized for the broken 'return ret' *above* the one which gets
> rightfully fixed in this patch.
> 

Agreed, 2 broken cases and this is only fixing the second one.
I'm expecting a v2 of this patch which fixes them both, so 
won't apply this v1.

Thanks,

Jonathan

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

end of thread, other threads:[~2019-07-14 15:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-04 11:37 [PATCH] iio: adc: gyroadc: fix uninitialized return code Arnd Bergmann
2019-07-04 11:49 ` Geert Uytterhoeven
2019-07-04 12:07 ` Wolfram Sang
2019-07-04 12:10   ` Geert Uytterhoeven
2019-07-04 15:27     ` Marek Vasut
2019-07-04 19:55       ` Wolfram Sang
2019-07-14 15:09         ` 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).