Skip to content

Commit 74a96d0

Browse files
srishanmvijay-suman
authored andcommitted
drm/amd/display: Add null checks for 'stream' and 'plane' before dereferencing
commit 15c2990 upstream. 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]> Signed-off-by: Zhi Yang <[email protected]> Signed-off-by: He Zhe <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit fcf9d6a9f30ea414b6b84a6e901cebd44e146847) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent ecedc62 commit 74a96d0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,9 @@ bool dcn30_apply_idle_power_optimizations(struct dc *dc, bool enable)
784784
stream = dc->current_state->streams[0];
785785
plane = (stream ? dc->current_state->stream_status[0].plane_states[0] : NULL);
786786

787+
if (!stream || !plane)
788+
return false;
789+
787790
if (stream && plane) {
788791
cursor_cache_enable = stream->cursor_position.enable &&
789792
plane->address.grph.cursor_cache_addr.quad_part;

0 commit comments

Comments
 (0)