Reviewed-by: Tom Chung <[email protected]>

On 7/25/2024 10:54 AM, Srinivasan Shanmugam wrote:
This commit addresses a null pointer dereference issue in the
`commit_planes_for_stream` function at line 4140. The issue could occur
when `top_pipe_to_program` is null.

The fix adds a check to ensure `top_pipe_to_program` is not null before
accessing its stream_res. This prevents a null pointer dereference.

Reported by smatch:
drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc.c:4140 
commit_planes_for_stream() error: we previously assumed 'top_pipe_to_program' 
could be null (see line 3906)

Cc: Tom Chung <[email protected]>
Cc: Rodrigo Siqueira <[email protected]>
Cc: Roman Li <[email protected]>
Cc: Alex Hung <[email protected]>
Cc: Aurabindo Pillai <[email protected]>
Cc: Harry Wentland <[email protected]>
Cc: Hamza Mahfooz <[email protected]>
Signed-off-by: Srinivasan Shanmugam <[email protected]>
---
  drivers/gpu/drm/amd/display/dc/core/dc.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index b8a6c062426d..95d6e29d5e47 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -4137,7 +4137,8 @@ static void commit_planes_for_stream(struct dc *dc,
        }
if ((update_type != UPDATE_TYPE_FAST) && stream->update_flags.bits.dsc_changed)
-               if 
(top_pipe_to_program->stream_res.tg->funcs->lock_doublebuffer_enable) {
+               if (top_pipe_to_program &&
+                   
top_pipe_to_program->stream_res.tg->funcs->lock_doublebuffer_enable) {
                        
top_pipe_to_program->stream_res.tg->funcs->wait_for_state(
                                top_pipe_to_program->stream_res.tg,
                                CRTC_STATE_VACTIVE);

Reply via email to