]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amd/display: Avoid NULL dereference of timing generator
authorWayne Lin <wayne.lin@amd.com>
Fri, 8 Sep 2023 02:14:49 +0000 (10:14 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Nov 2023 16:56:20 +0000 (16:56 +0000)
[ Upstream commit b1904ed480cee3f9f4036ea0e36d139cb5fee2d6 ]

[Why & How]
Check whether assigned timing generator is NULL or not before
accessing its funcs to prevent NULL dereference.

Reviewed-by: Jun Lei <jun.lei@amd.com>
Acked-by: Hersen Wu <hersenxs.wu@amd.com>
Signed-off-by: Wayne Lin <wayne.lin@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/display/dc/core/dc_stream.c

index f0f54f4d3d9bc16b4321dc7d8b99a47c02fdaad3..5dd57cf170f513951faaaeb38eabba6cb6cdb089 100644 (file)
@@ -562,7 +562,7 @@ uint32_t dc_stream_get_vblank_counter(const struct dc_stream_state *stream)
        for (i = 0; i < MAX_PIPES; i++) {
                struct timing_generator *tg = res_ctx->pipe_ctx[i].stream_res.tg;
 
-               if (res_ctx->pipe_ctx[i].stream != stream)
+               if (res_ctx->pipe_ctx[i].stream != stream || !tg)
                        continue;
 
                return tg->funcs->get_frame_count(tg);
@@ -621,7 +621,7 @@ bool dc_stream_get_scanoutpos(const struct dc_stream_state *stream,
        for (i = 0; i < MAX_PIPES; i++) {
                struct timing_generator *tg = res_ctx->pipe_ctx[i].stream_res.tg;
 
-               if (res_ctx->pipe_ctx[i].stream != stream)
+               if (res_ctx->pipe_ctx[i].stream != stream || !tg)
                        continue;
 
                tg->funcs->get_scanoutpos(tg,