Skip to contentSkip to conversation

acer-wmi: fix a problem that variable 'devices' may be used uninitialized

PATCH New Zhang Rui 1 participant 1 message Jan 16, 2013

Subsystems (2)
lore
Share & tools
lore

Zhang Rui

author
#0 lore raw

PATCH 1/1 acer-wmi: fix a problem that variable 'devices' may be used uninitialized

From fcf93a0a34fea5df219e579341c3a45aa3e90b8f Mon Sep 17 00:00:00 2001
From: Zhang Rui <[email protected]>
Date: Tue, 15 Jan 2013 09:05:23 +0800
Subject: [PATCH] acer-wmi: fix a problem that variable 'devices' may be used uninitialized

drivers/platform/x86/acer-wmi.c: In function ‘acer_wmi_init’:
drivers/platform/x86/acer-wmi.c:1216:14: warning: ‘devices’ may be used uninitialized in this function [-Wuninitialized] drivers/platform/x86/acer-wmi.c:1193:6: note: ‘devices’ was declared here

In WMID_set_capabilities(), 'devices' will be used uninitialized if the returned object is neither a buffer nor an integer.

---
 drivers/platform/x86/acer-wmi.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/platform/x86/acer-wmi.c +7 -8
index afed701..c471ad4 100644
@@ -1197,14 +1197,13 @@ static acpi_status WMID_set_capabilities(void)
 		return status;
 
 	obj = (union acpi_object *) out.pointer;
-	if (obj) {
-		if (obj->type == ACPI_TYPE_BUFFER &&
-			(obj->buffer.length == sizeof(u32) ||
-			obj->buffer.length == sizeof(u64))) {
-			devices = *((u32 *) obj->buffer.pointer);
-		} else if (obj->type == ACPI_TYPE_INTEGER) {
-			devices = (u32) obj->integer.value;
-		}
+
+	if (obj && obj->type == ACPI_TYPE_BUFFER &&
+		(obj->buffer.length == sizeof(u32) ||
+		obj->buffer.length == sizeof(u64))) {
+		devices = *((u32 *) obj->buffer.pointer);
+	} else if (obj && obj->type == ACPI_TYPE_INTEGER) {
+		devices = (u32) obj->integer.value;
 	} else {
 		kfree(out.pointer);
 		return AE_ERROR;
Signature · 1 line
1.7.9.5