Commit f20aaba9 authored by Lee, Chun-Yi's avatar Lee, Chun-Yi Committed by Matthew Garrett

acer-wmi: fix obj is NULL but dereferenced

Fengguang Wu run coccinelle and warns about:
  drivers/platform/x86/acer-wmi.c:1200:17-21: ERROR: obj is NULL but dereferenced.
  drivers/platform/x86/acer-wmi.c:891:17-21: ERROR: obj is NULL but dereferenced.
  drivers/platform/x86/acer-wmi.c:1953:17-21: ERROR: obj is NULL but dereferenced.

It causes by the code in patch 987dfbaa doesn't check
obj variable should not be NULL. There have risk for dereference a NULL obj, so add
this patch to fix.

Cc: Carlos Corbacho <carlos@strangeworlds.co.uk>
Cc: Matthew Garrett <mjg@redhat.com>
Cc: Dmitry Torokhov <dtor@mail.ru>
Cc: Corentin Chary <corentincj@iksaif.net>
Cc: Thomas Renninger <trenn@suse.de>
Signed-off-by: default avatarLee, Chun-Yi <jlee@suse.com>
Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
parent 182ae55c
...@@ -875,7 +875,7 @@ WMI_execute_u32(u32 method_id, u32 in, u32 *out) ...@@ -875,7 +875,7 @@ WMI_execute_u32(u32 method_id, u32 in, u32 *out)
struct acpi_buffer input = { (acpi_size) sizeof(u32), (void *)(&in) }; struct acpi_buffer input = { (acpi_size) sizeof(u32), (void *)(&in) };
struct acpi_buffer result = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_buffer result = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *obj; union acpi_object *obj;
u32 tmp; u32 tmp = 0;
acpi_status status; acpi_status status;
status = wmi_evaluate_method(WMID_GUID1, 1, method_id, &input, &result); status = wmi_evaluate_method(WMID_GUID1, 1, method_id, &input, &result);
...@@ -884,14 +884,14 @@ WMI_execute_u32(u32 method_id, u32 in, u32 *out) ...@@ -884,14 +884,14 @@ WMI_execute_u32(u32 method_id, u32 in, u32 *out)
return status; return status;
obj = (union acpi_object *) result.pointer; obj = (union acpi_object *) result.pointer;
if (obj && obj->type == ACPI_TYPE_BUFFER && if (obj) {
(obj->buffer.length == sizeof(u32) || if (obj->type == ACPI_TYPE_BUFFER &&
obj->buffer.length == sizeof(u64))) { (obj->buffer.length == sizeof(u32) ||
tmp = *((u32 *) obj->buffer.pointer); obj->buffer.length == sizeof(u64))) {
} else if (obj->type == ACPI_TYPE_INTEGER) { tmp = *((u32 *) obj->buffer.pointer);
tmp = (u32) obj->integer.value; } else if (obj->type == ACPI_TYPE_INTEGER) {
} else { tmp = (u32) obj->integer.value;
tmp = 0; }
} }
if (out) if (out)
...@@ -1193,12 +1193,14 @@ static acpi_status WMID_set_capabilities(void) ...@@ -1193,12 +1193,14 @@ static acpi_status WMID_set_capabilities(void)
return status; return status;
obj = (union acpi_object *) out.pointer; obj = (union acpi_object *) out.pointer;
if (obj && obj->type == ACPI_TYPE_BUFFER && if (obj) {
(obj->buffer.length == sizeof(u32) || if (obj->type == ACPI_TYPE_BUFFER &&
obj->buffer.length == sizeof(u64))) { (obj->buffer.length == sizeof(u32) ||
devices = *((u32 *) obj->buffer.pointer); obj->buffer.length == sizeof(u64))) {
} else if (obj->type == ACPI_TYPE_INTEGER) { devices = *((u32 *) obj->buffer.pointer);
devices = (u32) obj->integer.value; } else if (obj->type == ACPI_TYPE_INTEGER) {
devices = (u32) obj->integer.value;
}
} else { } else {
kfree(out.pointer); kfree(out.pointer);
return AE_ERROR; return AE_ERROR;
...@@ -1946,12 +1948,14 @@ static u32 get_wmid_devices(void) ...@@ -1946,12 +1948,14 @@ static u32 get_wmid_devices(void)
return 0; return 0;
obj = (union acpi_object *) out.pointer; obj = (union acpi_object *) out.pointer;
if (obj && obj->type == ACPI_TYPE_BUFFER && if (obj) {
(obj->buffer.length == sizeof(u32) || if (obj->type == ACPI_TYPE_BUFFER &&
obj->buffer.length == sizeof(u64))) { (obj->buffer.length == sizeof(u32) ||
devices = *((u32 *) obj->buffer.pointer); obj->buffer.length == sizeof(u64))) {
} else if (obj->type == ACPI_TYPE_INTEGER) { devices = *((u32 *) obj->buffer.pointer);
devices = (u32) obj->integer.value; } else if (obj->type == ACPI_TYPE_INTEGER) {
devices = (u32) obj->integer.value;
}
} }
kfree(out.pointer); kfree(out.pointer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment