]> www.infradead.org Git - users/hch/configfs.git/commitdiff
drm/amd/display: Add null check for 'afb' in amdgpu_dm_update_cursor (v2)
authorSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Fri, 2 Aug 2024 06:50:36 +0000 (12:20 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 13 Aug 2024 14:31:26 +0000 (10:31 -0400)
This commit adds a null check for the 'afb' variable in the
amdgpu_dm_update_cursor function. Previously, 'afb' was assumed to be
null at line 8388, but was used later in the code without a null check.
This could potentially lead to a null pointer dereference.

Changes since v1:
- Moved the null check for 'afb' to the line where 'afb' is used. (Alex)

Fixes the below:
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:8433 amdgpu_dm_update_cursor()
error: we previously assumed 'afb' could be null (see line 8388)

Cc: Tom Chung <chiahsuan.chung@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Roman Li <roman.li@amd.com>
Cc: Alex Hung <alex.hung@amd.com>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Co-developed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: Tom Chung <chiahsuan.chung@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index 454d205e4501b8aba43bf83674096574de8c1861..7d999e352df3b031eb1b3fc2e5a51acd2d4f13d8 100644 (file)
@@ -8696,7 +8696,8 @@ static void amdgpu_dm_update_cursor(struct drm_plane *plane,
            adev->dm.dc->caps.color.dpp.gamma_corr)
                attributes.attribute_flags.bits.ENABLE_CURSOR_DEGAMMA = 1;
 
-       attributes.pitch = afb->base.pitches[0] / afb->base.format->cpp[0];
+       if (afb)
+               attributes.pitch = afb->base.pitches[0] / afb->base.format->cpp[0];
 
        if (crtc_state->stream) {
                if (!dc_stream_set_cursor_attributes(crtc_state->stream,