aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorLee, Chun-Yi <joeyli.kernel@gmail.com>2012-12-14 03:14:26 -0500
committerMatthew Garrett <matthew.garrett@nebula.com>2013-01-07 12:31:30 -0500
commitf20aaba9819d0801fb1314363f97239da0100bac (patch)
tree5b6bff7041a69808997cb2857ddce701a24f9d77 /drivers/platform
parent182ae55c1285080086cf4ef969ad09d84e00237f (diff)
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 987dfbaa65b2c3568b85e29d2598da08a011ee09 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: Lee, Chun-Yi <jlee@suse.com> Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/acer-wmi.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
index 06f4eb7ab87e..ff0a866791ca 100644
--- a/drivers/platform/x86/acer-wmi.c
+++ b/drivers/platform/x86/acer-wmi.c
@@ -875,7 +875,7 @@ WMI_execute_u32(u32 method_id, u32 in, u32 *out)
875 struct acpi_buffer input = { (acpi_size) sizeof(u32), (void *)(&in) }; 875 struct acpi_buffer input = { (acpi_size) sizeof(u32), (void *)(&in) };
876 struct acpi_buffer result = { ACPI_ALLOCATE_BUFFER, NULL }; 876 struct acpi_buffer result = { ACPI_ALLOCATE_BUFFER, NULL };
877 union acpi_object *obj; 877 union acpi_object *obj;
878 u32 tmp; 878 u32 tmp = 0;
879 acpi_status status; 879 acpi_status status;
880 880
881 status = wmi_evaluate_method(WMID_GUID1, 1, method_id, &input, &result); 881 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 return status; 884 return status;
885 885
886 obj = (union acpi_object *) result.pointer; 886 obj = (union acpi_object *) result.pointer;
887 if (obj && obj->type == ACPI_TYPE_BUFFER && 887 if (obj) {
888 (obj->buffer.length == sizeof(u32) || 888 if (obj->type == ACPI_TYPE_BUFFER &&
889 obj->buffer.length == sizeof(u64))) { 889 (obj->buffer.length == sizeof(u32) ||
890 tmp = *((u32 *) obj->buffer.pointer); 890 obj->buffer.length == sizeof(u64))) {
891 } else if (obj->type == ACPI_TYPE_INTEGER) { 891 tmp = *((u32 *) obj->buffer.pointer);
892 tmp = (u32) obj->integer.value; 892 } else if (obj->type == ACPI_TYPE_INTEGER) {
893 } else { 893 tmp = (u32) obj->integer.value;
894 tmp = 0; 894 }
895 } 895 }
896 896
897 if (out) 897 if (out)
@@ -1193,12 +1193,14 @@ static acpi_status WMID_set_capabilities(void)
1193 return status; 1193 return status;
1194 1194
1195 obj = (union acpi_object *) out.pointer; 1195 obj = (union acpi_object *) out.pointer;
1196 if (obj && obj->type == ACPI_TYPE_BUFFER && 1196 if (obj) {
1197 (obj->buffer.length == sizeof(u32) || 1197 if (obj->type == ACPI_TYPE_BUFFER &&
1198 obj->buffer.length == sizeof(u64))) { 1198 (obj->buffer.length == sizeof(u32) ||
1199 devices = *((u32 *) obj->buffer.pointer); 1199 obj->buffer.length == sizeof(u64))) {
1200 } else if (obj->type == ACPI_TYPE_INTEGER) { 1200 devices = *((u32 *) obj->buffer.pointer);
1201 devices = (u32) obj->integer.value; 1201 } else if (obj->type == ACPI_TYPE_INTEGER) {
1202 devices = (u32) obj->integer.value;
1203 }
1202 } else { 1204 } else {
1203 kfree(out.pointer); 1205 kfree(out.pointer);
1204 return AE_ERROR; 1206 return AE_ERROR;
@@ -1946,12 +1948,14 @@ static u32 get_wmid_devices(void)
1946 return 0; 1948 return 0;
1947 1949
1948 obj = (union acpi_object *) out.pointer; 1950 obj = (union acpi_object *) out.pointer;
1949 if (obj && obj->type == ACPI_TYPE_BUFFER && 1951 if (obj) {
1950 (obj->buffer.length == sizeof(u32) || 1952 if (obj->type == ACPI_TYPE_BUFFER &&
1951 obj->buffer.length == sizeof(u64))) { 1953 (obj->buffer.length == sizeof(u32) ||
1952 devices = *((u32 *) obj->buffer.pointer); 1954 obj->buffer.length == sizeof(u64))) {
1953 } else if (obj->type == ACPI_TYPE_INTEGER) { 1955 devices = *((u32 *) obj->buffer.pointer);
1954 devices = (u32) obj->integer.value; 1956 } else if (obj->type == ACPI_TYPE_INTEGER) {
1957 devices = (u32) obj->integer.value;
1958 }
1955 } 1959 }
1956 1960
1957 kfree(out.pointer); 1961 kfree(out.pointer);