Skip to content

Commit 9dd8e2b

Browse files
TencentAISecalexdeucher
authored andcommitted
drm/amd/display: fix a Null pointer dereference vulnerability
[Why] A null pointer dereference vulnerability exists in the AMD display driver's (DC module) cleanup function dc_destruct(). When display control context (dc->ctx) construction fails (due to memory allocation failure), this pointer remains NULL. During subsequent error handling when dc_destruct() is called, there's no NULL check before dereferencing the perf_trace member (dc->ctx->perf_trace), causing a kernel null pointer dereference crash. [How] Check if dc->ctx is non-NULL before dereferencing. Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Mario Limonciello <[email protected]> Signed-off-by: Mario Limonciello <[email protected]> (Updated commit text and removed unnecessary error message) Signed-off-by: Siyang Liu <[email protected]> Signed-off-by: Roman Li <[email protected]> Reviewed-by: Alex Hung <[email protected]> Tested-by: Daniel Wheeler <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 82594ac commit 9dd8e2b

File tree

1 file changed

+10
-9
lines changed
  • drivers/gpu/drm/amd/display/dc/core

1 file changed

+10
-9
lines changed

drivers/gpu/drm/amd/display/dc/core/dc.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -940,17 +940,18 @@ static void dc_destruct(struct dc *dc)
940940
if (dc->link_srv)
941941
link_destroy_link_service(&dc->link_srv);
942942

943-
if (dc->ctx->gpio_service)
944-
dal_gpio_service_destroy(&dc->ctx->gpio_service);
943+
if (dc->ctx) {
944+
if (dc->ctx->gpio_service)
945+
dal_gpio_service_destroy(&dc->ctx->gpio_service);
945946

946-
if (dc->ctx->created_bios)
947-
dal_bios_parser_destroy(&dc->ctx->dc_bios);
947+
if (dc->ctx->created_bios)
948+
dal_bios_parser_destroy(&dc->ctx->dc_bios);
949+
kfree(dc->ctx->logger);
950+
dc_perf_trace_destroy(&dc->ctx->perf_trace);
948951

949-
kfree(dc->ctx->logger);
950-
dc_perf_trace_destroy(&dc->ctx->perf_trace);
951-
952-
kfree(dc->ctx);
953-
dc->ctx = NULL;
952+
kfree(dc->ctx);
953+
dc->ctx = NULL;
954+
}
954955

955956
kfree(dc->bw_vbios);
956957
dc->bw_vbios = NULL;

0 commit comments

Comments
 (0)