Skip to contentSkip to conversation

sony-laptop - fix using of uninitialized variable

PATCH Applied Dmitry Torokhov 3 participants 3 messages Jan 10, 2010 – Jan 16, 2010

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

PATCH 1/1 sony-laptop - fix using of uninitialized variable

CC [M] drivers/platform/x86/sony-laptop.o
drivers/platform/x86/sony-laptop.c: In function 'sony_nc_rfkill_setup':
drivers/platform/x86/sony-laptop.c:1162: warning: 'i' may be used uninitialized in this function

---

This is a real warning and without the fix we may be setting up non-existing rfkill devices so please consider for .33.

 drivers/platform/x86/sony-laptop.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
drivers/platform/x86/sony-laptop.c +6 -3
index 5af5334..3f71a60 100644
@@ -1201,9 +1201,12 @@ static void sony_nc_rfkill_setup(struct acpi_device *device)
 	/* the buffer is filled with magic numbers describing the devices
 	 * available, 0xff terminates the enumeration
 	 */
-	while ((dev_code = *(device_enum->buffer.pointer + i)) != 0xff &&
-			i < device_enum->buffer.length) {
-		i++;
+	for (i = 0; i < device_enum->buffer.length; i++) {
+
+		dev_code = *(device_enum->buffer.pointer + i);
+		if (dev_code == 0xff)
+			break;
+
 		dprintk("Radio devices, looking at 0x%.2x\n", dev_code);
 
 		if (dev_code == 0 && !sony_rfkill_devices[SONY_WIFI])
Signature · 1 line
Dmitry
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Dmitry Torokhov

CC [M] drivers/platform/x86/sony-laptop.o
drivers/platform/x86/sony-laptop.c: In function 'sony_nc_rfkill_setup':
drivers/platform/x86/sony-laptop.c:1162: warning: 'i' may be used uninitialized in this function

---

This is a real warning and without the fix we may be setting up non-existing rfkill devices so please consider for .33.

Thanks Dmitry.

Len, please submit this for 2.6.33 and add my

Signature · 2 lines
mattia
:wq!
reviewer Applied
#2 lore raw

applied

thanks,
Len Brown, Intel Open Source Technology Center