Skip to content

Commit 0961673

Browse files
TencentAISecgregkh
authored andcommitted
drm/amd/display: fix a Null pointer dereference vulnerability
commit 1bcf63a upstream. [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/tencent_54FF4252EDFB6533090A491A25EEF3EDBF06@qq.com Co-developed-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> (Updated commit text and removed unnecessary error message) Signed-off-by: Siyang Liu <Security@tencent.com> Signed-off-by: Roman Li <roman.li@amd.com> Reviewed-by: Alex Hung <alex.hung@amd.com> Tested-by: Daniel Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 9dd8e2b) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent de0780d commit 0961673

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
@@ -890,17 +890,18 @@ static void dc_destruct(struct dc *dc)
890890
if (dc->link_srv)
891891
link_destroy_link_service(&dc->link_srv);
892892

893-
if (dc->ctx->gpio_service)
894-
dal_gpio_service_destroy(&dc->ctx->gpio_service);
893+
if (dc->ctx) {
894+
if (dc->ctx->gpio_service)
895+
dal_gpio_service_destroy(&dc->ctx->gpio_service);
895896

896-
if (dc->ctx->created_bios)
897-
dal_bios_parser_destroy(&dc->ctx->dc_bios);
897+
if (dc->ctx->created_bios)
898+
dal_bios_parser_destroy(&dc->ctx->dc_bios);
899+
kfree(dc->ctx->logger);
900+
dc_perf_trace_destroy(&dc->ctx->perf_trace);
898901

899-
kfree(dc->ctx->logger);
900-
dc_perf_trace_destroy(&dc->ctx->perf_trace);
901-
902-
kfree(dc->ctx);
903-
dc->ctx = NULL;
902+
kfree(dc->ctx);
903+
dc->ctx = NULL;
904+
}
904905

905906
kfree(dc->bw_vbios);
906907
dc->bw_vbios = NULL;

0 commit comments

Comments
 (0)