]> Git Repo - J-linux.git/commitdiff
drm/amd/display: Add null checks for 'stream' and 'plane' before dereferencing
authorSrinivasan Shanmugam <[email protected]>
Mon, 27 May 2024 14:45:21 +0000 (20:15 +0530)
committerAlex Deucher <[email protected]>
Wed, 5 Jun 2024 15:25:14 +0000 (11:25 -0400)
This commit adds null checks for the 'stream' and 'plane' variables in
the dcn30_apply_idle_power_optimizations function. These variables were
previously assumed to be null at line 922, but they were used later in
the code without checking if they were null. This could potentially lead
to a null pointer dereference, which would cause a crash.

The null checks ensure that 'stream' and 'plane' are not null before
they are used, preventing potential crashes.

Fixes the below static smatch checker:
drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn30/dcn30_hwseq.c:938 dcn30_apply_idle_power_optimizations() error: we previously assumed 'stream' could be null (see line 922)
drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn30/dcn30_hwseq.c:940 dcn30_apply_idle_power_optimizations() error: we previously assumed 'plane' could be null (see line 922)

Cc: Tom Chung <[email protected]>
Cc: Nicholas Kazlauskas <[email protected]>
Cc: Bhawanpreet Lakha <[email protected]>
Cc: Rodrigo Siqueira <[email protected]>
Cc: Roman Li <[email protected]>
Cc: Hersen Wu <[email protected]>
Cc: Alex Hung <[email protected]>
Cc: Aurabindo Pillai <[email protected]>
Cc: Harry Wentland <[email protected]>
Signed-off-by: Srinivasan Shanmugam <[email protected]>
Reviewed-by: Aurabindo Pillai <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.c

index 29d1f150846a4e77ec33054c603ced23b850044c..4c4706153305097e36945a880c54fba60d3bd554 100644 (file)
@@ -919,6 +919,9 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable)
                        stream = dc->current_state->streams[0];
                        plane = (stream ? dc->current_state->stream_status[0].plane_states[0] : NULL);
 
+                       if (!stream || !plane)
+                               return false;
+
                        if (stream && plane) {
                                cursor_cache_enable = stream->cursor_position.enable &&
                                                plane->address.grph.cursor_cache_addr.quad_part;
This page took 0.083339 seconds and 4 git commands to generate.