drm/amd/display: Avoid NULL dereference of timing generator
authorjsg <jsg@openbsd.org>
Thu, 30 Nov 2023 02:38:28 +0000 (02:38 +0000)
committerjsg <jsg@openbsd.org>
Thu, 30 Nov 2023 02:38:28 +0000 (02:38 +0000)
From Wayne Lin
8a06894666e0b462c9316b26ab615cefdd0d676c in linux-6.1.y/6.1.64
b1904ed480cee3f9f4036ea0e36d139cb5fee2d6 in mainline linux

sys/dev/pci/drm/amd/display/dc/core/dc_stream.c

index 38d71b5..556c57c 100644 (file)
@@ -567,7 +567,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);
@@ -626,7 +626,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,