[PATCH] acer-wmi: do not use 'devices' uninitialized

From: Paul Bolle
Date: Thu Jan 24 2013 - 08:14:00 EST


Commit f20aaba9819d0801fb1314363f97239da0100bac ("acer-wmi: fix obj is
NULL but dereferenced") introduced a GCC warning:
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 [-Wmaybe-uninitialized]
drivers/platform/x86/acer-wmi.c:1193:6: note: âdevicesâ was declared here

GCC is correct. In WMID_set_capabilities() there are now clearly codepaths
that use 'devices' uninitialized. (WMID_set_capabilities() is apparently
inlined in acer_wmi_init().) Previously that couldn't happen. So rework
the code to use the previous logic, but also make sure 'obj' will not be
dereferenced while NULL.

Signed-off-by: Paul Bolle <pebolle@xxxxxxxxxx>
---
Compile tested only!

drivers/platform/x86/acer-wmi.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index afed701..0ddac19 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -1197,14 +1197,12 @@ static acpi_status WMID_set_capabilities(void)
return status;

obj = (union acpi_object *) out.pointer;
- if (obj) {
- if (obj->type == ACPI_TYPE_BUFFER &&
+ 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->type == ACPI_TYPE_INTEGER) {
+ } else if (obj && obj->type == ACPI_TYPE_INTEGER) {
devices = (u32) obj->integer.value;
- }
} else {
kfree(out.pointer);
return AE_ERROR;
--
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/