]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amd/display: Add null check for 'afb' in amdgpu_dm_plane_handle_cursor_update...
authorSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Fri, 2 Aug 2024 07:05:13 +0000 (12:35 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Oct 2024 10:00:31 +0000 (12:00 +0200)
[ Upstream commit cd9e9e0852d501f169aa3bb34e4b413d2eb48c37 ]

This commit adds a null check for the 'afb' variable in the
amdgpu_dm_plane_handle_cursor_update function. Previously, 'afb' was
assumed to be null, 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_plane.c:1298 amdgpu_dm_plane_handle_cursor_update() error: we previously assumed 'afb' could be null (see line 1252)

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c

index 7d47acdd11d55b7e5edc5be502cc3e8f0ea01942..fe7a99aee47dd53f6de517ac600839292bade79c 100644 (file)
@@ -1285,7 +1285,8 @@ void amdgpu_dm_plane_handle_cursor_update(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) {
                mutex_lock(&adev->dm.dc_lock);