Skip to contentSkip to conversation

ideapad: uninitialized data in ideapad_acpi_add()

PATCH In review Dan Carpenter 2 participants 4 messages Jun 12, 2012 – Jun 28, 2012

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

PATCH 1/1 ideapad: uninitialized data in ideapad_acpi_add()

We only initialize the high bits of "cfg". It probably doesn't cause a problem given that this is platform specific code and doesn't have to worry about endianness etc. But it's sort of messy.

---
This is a static checker fix and I don't have the hardware. Sorry.

drivers/platform/x86/ideapad-laptop.c +3 -3
index 4f20f8d..17f6dfd 100644
@@ -694,10 +694,10 @@ MODULE_DEVICE_TABLE(acpi, ideapad_device_ids);
 static int __devinit ideapad_acpi_add(struct acpi_device *adevice)
 {
 	int ret, i;
-	unsigned long cfg;
+	int cfg;
 	struct ideapad_private *priv;
 
-	if (read_method_int(adevice->handle, "_CFG", (int *)&cfg))
+	if (read_method_int(adevice->handle, "_CFG", &cfg))
 		return -ENODEV;
 
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -721,7 +721,7 @@ static int __devinit ideapad_acpi_add(struct acpi_device *adevice)
 		goto input_failed;
 
 	for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) {
-		if (test_bit(ideapad_rfk_data[i].cfgbit, &cfg))
+		if (test_bit(ideapad_rfk_data[i].cfgbit, &priv->cfg))
 			ideapad_register_rfkill(adevice, i);
 		else
 			priv->rfk[i] = NULL;
#1 lore raw

Hi Dan,

# cat /sys/kernel/debug/ideapad/cfg
cfg: 0xFFFF8800007DE140
       ^^^^^^^^ the uninitialized bit

I see your point, perhaps unsigned int will be better then int?

Quoted 39 lines · Dan Carpenter

We only initialize the high bits of "cfg". It probably doesn't cause a problem given that this is platform specific code and doesn't have to worry about endianness etc. But it's sort of messy.

---
This is a static checker fix and I don't have the hardware. Sorry.

drivers/platform/x86/ideapad-laptop.c +3 -4
index 4f20f8d..17f6dfd 100644
@@ -694,10 +694,10 @@ MODULE_DEVICE_TABLE(acpi, ideapad_device_ids);
 static int __devinit ideapad_acpi_add(struct acpi_device *adevice)
 {
 	int ret, i;
-	unsigned long cfg;
+	int cfg;
 	struct ideapad_private *priv;
 
-	if (read_method_int(adevice->handle, "_CFG", (int *)&cfg))
+	if (read_method_int(adevice->handle, "_CFG", &cfg))
 		return -ENODEV;
 
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -721,7 +721,7 @@ static int __devinit ideapad_acpi_add(struct acpi_device *adevice)
 		goto input_failed;
 
 	for (i = 0; i < IDEAPAD_RFKILL_DEV_NUM; i++) {
-		if (test_bit(ideapad_rfk_data[i].cfgbit, &cfg))
+		if (test_bit(ideapad_rfk_data[i].cfgbit, &priv->cfg))
 			ideapad_register_rfkill(adevice, i);
 		else
 			priv->rfk[i] = NULL;
--

To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 8 lines · Ike Panhc

Hi Dan,

# cat /sys/kernel/debug/ideapad/cfg
cfg: 0xFFFF8800007DE140
       ^^^^^^^^ the uninitialized bit

I see your point, perhaps unsigned int will be better then int?

I don't know if this is a question or a resend request.

I just chose that base on the fact that we are reading an int from ACPI in read_method_int(adevice->handle, "_CFG", &cfg). Either way we're going to run into integer conversion issues if we get passed a large or negative int.

I can resend if you want, I don't have strong feelings on this.

regards,
dan carpenter

#3 lore raw
Quoted 17 lines · Dan Carpenter
Quoted 8 lines · Ike Panhc

Hi Dan,

# cat /sys/kernel/debug/ideapad/cfg
cfg: 0xFFFF8800007DE140
       ^^^^^^^^ the uninitialized bit

I see your point, perhaps unsigned int will be better then int?

I don't know if this is a question or a resend request.

I just chose that base on the fact that we are reading an int from ACPI in read_method_int(adevice->handle, "_CFG", &cfg). Either way we're going to run into integer conversion issues if we get passed a large or negative int.

Quoted 5 lines

I can resend if you want, I don't have strong feelings on this.

regards,
dan carpenter

ah, I asked stupid question. Never mind.

Thanks for your report.