Skip to contentSkip to conversation

backlight: adp8860: fix another uninitialized variable use

PATCH In review Arnd Bergmann 4 participants 4 messages Nov 30, 2015 – Jan 11, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 backlight: adp8860: fix another uninitialized variable use

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.

Fixes 6be3a5a9cd91 ("backlight: adp88x0: Fix uninitialized variable use")

---
Sorry for missing this third hunk the first time around.

drivers/video/backlight/adp8860_bl.c +5 -3
index f0d4c0324580..510e559c060e 100644
@@ -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, &reg_val);
-	ret_val = reg_val;
-	error |= adp8860_read(data->client, ADP8860_PH1LEVH, &reg_val);
+	if (!error) {
+		ret_val = reg_val;
+		error = adp8860_read(data->client, ADP8860_PH1LEVH, &reg_val);
+	}
 	mutex_unlock(&data->lock);
 
-	if (error < 0)
+	if (error)
 		return error;
 
 	/* Return 13-bit conversion value for the first light sensor */
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Arnd Bergmann

A recent patch I did fixed two potential uses of uninitialized variables in the adp8870 and adp8860 drivers. Unfortunately, I missed another one:

Quoted 8 lines

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.

Quoted 26 lines
Fixes 6be3a5a9cd91 ("backlight: adp88x0: Fix uninitialized variable use")

---
Sorry for missing this third hunk the first time around.

drivers/video/backlight/adp8860_bl.c +5 -3
index f0d4c0324580..510e559c060e 100644
@@ -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, &reg_val);
-	ret_val = reg_val;
-	error |= adp8860_read(data->client, ADP8860_PH1LEVH, &reg_val);
+	if (!error) {
+		ret_val = reg_val;
+		error = adp8860_read(data->client, ADP8860_PH1LEVH, &reg_val);
+	}
  	mutex_unlock(&data->lock);
 
-	if (error < 0)
+	if (error)
  		return error;
 
  	/* Return 13-bit conversion value for the first light sensor */
Signature · 8 lines
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
maintainer Acked-by
#2 lore raw
Quoted 9 lines · Michael Hennerich
Quoted 6 lines · Arnd Bergmann

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

Quoted 1 line
Quoted 7 lines
Quoted 5 lines

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.

Best regards,
Jingoo Han

Quoted 38 lines
Quoted 17 lines
Fixes 6be3a5a9cd91 ("backlight: adp88x0: Fix uninitialized variable use")

---
Sorry for missing this third hunk the first time around.

drivers/video/backlight/adp8860_bl.c +1 -2
index f0d4c0324580..510e559c060e 100644
@@ -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, &reg_val);
-	ret_val = reg_val;
-	error |= adp8860_read(data->client, ADP8860_PH1LEVH, &reg_val);
+	if (!error) {

drivers/video/backlight/adp8860_bl.c static ssize_t adp8860_bl_ambient_light_level_show(struct device *dev, · line 578

Quoted 10 lines
drivers/video/backlight/adp8860_bl.c +4 -1
+		ret_val = reg_val;
+		error = adp8860_read(data->client, ADP8860_PH1LEVH, &reg_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

#3 lore raw
In reply to Arnd Bergmann
Quoted 7 lines · Arnd Bergmann

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

Quoted 8 lines

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.

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.

Quoted 22 lines
drivers/video/backlight/adp8860_bl.c +5 -3
index f0d4c0324580..510e559c060e 100644
@@ -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, &reg_val);
-	ret_val = reg_val;
-	error |= adp8860_read(data->client, ADP8860_PH1LEVH, &reg_val);
+	if (!error) {
+		ret_val = reg_val;
+		error = adp8860_read(data->client, ADP8860_PH1LEVH, &reg_val);
+	}
 	mutex_unlock(&data->lock);
 
-	if (error < 0)
+	if (error)
 		return error;
 
 	/* Return 13-bit conversion value for the first light sensor */
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog