]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/display: Fix NULL pointer dereference
authorMeenakshikumar Somasundaram <meenakshikumar.somasundaram@amd.com>
Mon, 29 Sep 2025 18:28:34 +0000 (14:28 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 21 Oct 2025 13:45:33 +0000 (09:45 -0400)
[Why]
On a mst branch with multi display setup, dc context is obselete
after updating the first stream. Referencing the same dc context
for the next stream update to fetch dc pointer leads to NULL
pointer dereference.

[How]
Get the dc pointer from the link rather than context.

Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Charlene Liu <charlene.liu@amd.com>
Signed-off-by: Meenakshikumar Somasundaram <meenakshikumar.somasundaram@amd.com>
Signed-off-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit dc69b48988b171d6ccb3a083607e4dff015e2c0d)
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c

index 9e33bf937a692426c4a52b6d5d16970452d54ae3..2676ae9f6fe8377c8048c1898e6717e76eb080a0 100644 (file)
@@ -78,6 +78,7 @@ static void dp_retrain_link_dp_test(struct dc_link *link,
        struct audio_output audio_output[MAX_PIPES];
        struct dc_stream_state *streams_on_link[MAX_PIPES];
        int num_streams_on_link = 0;
+       struct dc *dc = (struct dc *)link->dc;
 
        needs_divider_update = (link->dc->link_srv->dp_get_encoding_format(link_setting) !=
        link->dc->link_srv->dp_get_encoding_format((const struct dc_link_settings *) &link->cur_link_settings));
@@ -150,7 +151,7 @@ static void dp_retrain_link_dp_test(struct dc_link *link,
                if (streams_on_link[i] && streams_on_link[i]->link && streams_on_link[i]->link == link) {
                        stream_update.stream = streams_on_link[i];
                        stream_update.dpms_off = &dpms_off;
-                       dc_update_planes_and_stream(state->clk_mgr->ctx->dc, NULL, 0, streams_on_link[i], &stream_update);
+                       dc_update_planes_and_stream(dc, NULL, 0, streams_on_link[i], &stream_update);
                }
        }
 }