* [PATCH] backlight: adp8860: fix another uninitialized variable use
@ 2015-11-30 11:24 Arnd Bergmann
2015-12-01 9:32 ` Michael Hennerich
2016-01-11 7:57 ` Lee Jones
0 siblings, 2 replies; 4+ messages in thread
From: Arnd Bergmann @ 2015-11-30 11:24 UTC (permalink / raw)
To: linux-arm-kernel
A recent patch I did fixed two potential uses of uninitialized
variables in the adp8870 and adp8860 drivers. Unfortunately,
I missed another one:
drivers/video/backlight/adp8860_bl.c: In function 'adp8860_bl_ambient_light_level_show':
drivers/video/backlight/adp8860_bl.c:570:11: warning: 'reg_val' may be used uninitialized in this function
This does the same change as before in one additional function,
and also changes the check for the return value in a way that
avoids another false positive warning with a similar message.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 6be3a5a9cd91 ("backlight: adp88x0: Fix uninitialized variable use")
---
Sorry for missing this third hunk the first time around.
diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
index f0d4c0324580..510e559c060e 100644
--- a/drivers/video/backlight/adp8860_bl.c
+++ b/drivers/video/backlight/adp8860_bl.c
@@ -566,11 +566,13 @@ static ssize_t adp8860_bl_ambient_light_level_show(struct device *dev,
mutex_lock(&data->lock);
error = adp8860_read(data->client, ADP8860_PH1LEVL, ®_val);
- ret_val = reg_val;
- error |= adp8860_read(data->client, ADP8860_PH1LEVH, ®_val);
+ if (!error) {
+ ret_val = reg_val;
+ error = adp8860_read(data->client, ADP8860_PH1LEVH, ®_val);
+ }
mutex_unlock(&data->lock);
- if (error < 0)
+ if (error)
return error;
/* Return 13-bit conversion value for the first light sensor */
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] backlight: adp8860: fix another uninitialized variable use
2015-11-30 11:24 [PATCH] backlight: adp8860: fix another uninitialized variable use Arnd Bergmann
@ 2015-12-01 9:32 ` Michael Hennerich
2015-12-22 12:44 ` Jingoo Han
2016-01-11 7:57 ` Lee Jones
1 sibling, 1 reply; 4+ messages in thread
From: Michael Hennerich @ 2015-12-01 9:32 UTC (permalink / raw)
To: linux-arm-kernel
On 11/30/2015 12:24 PM, Arnd Bergmann wrote:
> A recent patch I did fixed two potential uses of uninitialized
> variables in the adp8870 and adp8860 drivers. Unfortunately,
> I missed another one:
>
> drivers/video/backlight/adp8860_bl.c: In function 'adp8860_bl_ambient_light_level_show':
> drivers/video/backlight/adp8860_bl.c:570:11: warning: 'reg_val' may be used uninitialized in this function
>
> This does the same change as before in one additional function,
> and also changes the check for the return value in a way that
> avoids another false positive warning with a similar message.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
> Fixes: 6be3a5a9cd91 ("backlight: adp88x0: Fix uninitialized variable use")
> ---
> Sorry for missing this third hunk the first time around.
>
> diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
> index f0d4c0324580..510e559c060e 100644
> --- a/drivers/video/backlight/adp8860_bl.c
> +++ b/drivers/video/backlight/adp8860_bl.c
> @@ -566,11 +566,13 @@ static ssize_t adp8860_bl_ambient_light_level_show(struct device *dev,
>
> mutex_lock(&data->lock);
> error = adp8860_read(data->client, ADP8860_PH1LEVL, ®_val);
> - ret_val = reg_val;
> - error |= adp8860_read(data->client, ADP8860_PH1LEVH, ®_val);
> + if (!error) {
> + ret_val = reg_val;
> + error = adp8860_read(data->client, ADP8860_PH1LEVH, ®_val);
> + }
> mutex_unlock(&data->lock);
>
> - if (error < 0)
> + if (error)
> return error;
>
> /* Return 13-bit conversion value for the first light sensor */
>
--
Greetings,
Michael
--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin,
Margaret Seif
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] backlight: adp8860: fix another uninitialized variable use
2015-12-01 9:32 ` Michael Hennerich
@ 2015-12-22 12:44 ` Jingoo Han
0 siblings, 0 replies; 4+ messages in thread
From: Jingoo Han @ 2015-12-22 12:44 UTC (permalink / raw)
To: linux-arm-kernel
On Tuesday, December 01, 2015 6:33 PM, Michael Hennerich wrote:
> On 11/30/2015 12:24 PM, Arnd Bergmann wrote:
> > A recent patch I did fixed two potential uses of uninitialized
> > variables in the adp8870 and adp8860 drivers. Unfortunately,
> > I missed another one:
> >
> > drivers/video/backlight/adp8860_bl.c: In function 'adp8860_bl_ambient_light_level_show':
> > drivers/video/backlight/adp8860_bl.c:570:11: warning: 'reg_val' may be used uninitialized in this
> function
> >
> > This does the same change as before in one additional function,
> > and also changes the check for the return value in a way that
> > avoids another false positive warning with a similar message.
> >
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
Best regards,
Jingoo Han
>
> > Fixes: 6be3a5a9cd91 ("backlight: adp88x0: Fix uninitialized variable use")
> > ---
> > Sorry for missing this third hunk the first time around.
> >
> > diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
> > index f0d4c0324580..510e559c060e 100644
> > --- a/drivers/video/backlight/adp8860_bl.c
> > +++ b/drivers/video/backlight/adp8860_bl.c
> > @@ -566,11 +566,13 @@ static ssize_t adp8860_bl_ambient_light_level_show(struct device *dev,
> >
> > mutex_lock(&data->lock);
> > error = adp8860_read(data->client, ADP8860_PH1LEVL, ®_val);
> > - ret_val = reg_val;
> > - error |= adp8860_read(data->client, ADP8860_PH1LEVH, ®_val);
> > + if (!error) {
> > + ret_val = reg_val;
> > + error = adp8860_read(data->client, ADP8860_PH1LEVH, ®_val);
> > + }
> > mutex_unlock(&data->lock);
> >
> > - if (error < 0)
> > + if (error)
> > return error;
> >
> > /* Return 13-bit conversion value for the first light sensor */
> >
>
>
> --
> Greetings,
> Michael
>
> --
> Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
> Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
> Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin,
> Margaret Seif
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] backlight: adp8860: fix another uninitialized variable use
2015-11-30 11:24 [PATCH] backlight: adp8860: fix another uninitialized variable use Arnd Bergmann
2015-12-01 9:32 ` Michael Hennerich
@ 2016-01-11 7:57 ` Lee Jones
1 sibling, 0 replies; 4+ messages in thread
From: Lee Jones @ 2016-01-11 7:57 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, 30 Nov 2015, Arnd Bergmann wrote:
> A recent patch I did fixed two potential uses of uninitialized
> variables in the adp8870 and adp8860 drivers. Unfortunately,
> I missed another one:
>
> drivers/video/backlight/adp8860_bl.c: In function 'adp8860_bl_ambient_light_level_show':
> drivers/video/backlight/adp8860_bl.c:570:11: warning: 'reg_val' may be used uninitialized in this function
>
> This does the same change as before in one additional function,
> and also changes the check for the return value in a way that
> avoids another false positive warning with a similar message.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 6be3a5a9cd91 ("backlight: adp88x0: Fix uninitialized variable use")
> ---
> Sorry for missing this third hunk the first time around.
Where's your diff?
Applied anyway, thanks.
> diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
> index f0d4c0324580..510e559c060e 100644
> --- a/drivers/video/backlight/adp8860_bl.c
> +++ b/drivers/video/backlight/adp8860_bl.c
> @@ -566,11 +566,13 @@ static ssize_t adp8860_bl_ambient_light_level_show(struct device *dev,
>
> mutex_lock(&data->lock);
> error = adp8860_read(data->client, ADP8860_PH1LEVL, ®_val);
> - ret_val = reg_val;
> - error |= adp8860_read(data->client, ADP8860_PH1LEVH, ®_val);
> + if (!error) {
> + ret_val = reg_val;
> + error = adp8860_read(data->client, ADP8860_PH1LEVH, ®_val);
> + }
> mutex_unlock(&data->lock);
>
> - if (error < 0)
> + if (error)
> return error;
>
> /* Return 13-bit conversion value for the first light sensor */
>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-01-11 7:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-30 11:24 [PATCH] backlight: adp8860: fix another uninitialized variable use Arnd Bergmann
2015-12-01 9:32 ` Michael Hennerich
2015-12-22 12:44 ` Jingoo Han
2016-01-11 7:57 ` Lee Jones
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).