Skip to content

Commit bf58f03

Browse files
superm1alexdeucher
authored andcommitted
drm/amd: Guard against bad data for ATIF ACPI method
If a BIOS provides bad data in response to an ATIF method call this causes a NULL pointer dereference in the caller. ``` ? show_regs (arch/x86/kernel/dumpstack.c:478 (discriminator 1)) ? __die (arch/x86/kernel/dumpstack.c:423 arch/x86/kernel/dumpstack.c:434) ? page_fault_oops (arch/x86/mm/fault.c:544 (discriminator 2) arch/x86/mm/fault.c:705 (discriminator 2)) ? do_user_addr_fault (arch/x86/mm/fault.c:440 (discriminator 1) arch/x86/mm/fault.c:1232 (discriminator 1)) ? acpi_ut_update_object_reference (drivers/acpi/acpica/utdelete.c:642) ? exc_page_fault (arch/x86/mm/fault.c:1542) ? asm_exc_page_fault (./arch/x86/include/asm/idtentry.h:623) ? amdgpu_atif_query_backlight_caps.constprop.0 (drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c:387 (discriminator 2)) amdgpu ? amdgpu_atif_query_backlight_caps.constprop.0 (drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c:386 (discriminator 1)) amdgpu ``` It has been encountered on at least one system, so guard for it. Fixes: d38ceaf ("drm/amdgpu: add core driver (v4)") Acked-by: Alex Deucher <[email protected]> Signed-off-by: Mario Limonciello <[email protected]> Signed-off-by: Alex Deucher <[email protected]> (cherry picked from commit c9b7c80) Cc: [email protected]
1 parent 42f7652 commit bf58f03

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ static union acpi_object *amdgpu_atif_call(struct amdgpu_atif *atif,
147147
struct acpi_buffer *params)
148148
{
149149
acpi_status status;
150+
union acpi_object *obj;
150151
union acpi_object atif_arg_elements[2];
151152
struct acpi_object_list atif_arg;
152153
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -169,16 +170,24 @@ static union acpi_object *amdgpu_atif_call(struct amdgpu_atif *atif,
169170

170171
status = acpi_evaluate_object(atif->handle, NULL, &atif_arg,
171172
&buffer);
173+
obj = (union acpi_object *)buffer.pointer;
172174

173-
/* Fail only if calling the method fails and ATIF is supported */
175+
/* Fail if calling the method fails and ATIF is supported */
174176
if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
175177
DRM_DEBUG_DRIVER("failed to evaluate ATIF got %s\n",
176178
acpi_format_exception(status));
177-
kfree(buffer.pointer);
179+
kfree(obj);
178180
return NULL;
179181
}
180182

181-
return buffer.pointer;
183+
if (obj->type != ACPI_TYPE_BUFFER) {
184+
DRM_DEBUG_DRIVER("bad object returned from ATIF: %d\n",
185+
obj->type);
186+
kfree(obj);
187+
return NULL;
188+
}
189+
190+
return obj;
182191
}
183192

184193
/**

0 commit comments

Comments
 (0)