Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amd/display: avoid using null object of framebuffer

Instead of using state->fb->obj[0] directly, get object from framebuffer
by calling drm_gem_fb_get_obj() and return error code when object is
null to avoid using null object of framebuffer.

Fixes: 5d945cbcd4b1 ("drm/amd/display: Create a file dedicated to planes")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Ma Ke and committed by
Alex Deucher
73dd0ad9 4416377a

+7 -2
+7 -2
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
··· 28 28 #include <drm/drm_blend.h> 29 29 #include <drm/drm_gem_atomic_helper.h> 30 30 #include <drm/drm_plane_helper.h> 31 + #include <drm/drm_gem_framebuffer_helper.h> 31 32 #include <drm/drm_fourcc.h> 32 33 33 34 #include "amdgpu.h" ··· 936 935 } 937 936 938 937 afb = to_amdgpu_framebuffer(new_state->fb); 939 - obj = new_state->fb->obj[0]; 938 + obj = drm_gem_fb_get_obj(new_state->fb, 0); 939 + if (!obj) { 940 + DRM_ERROR("Failed to get obj from framebuffer\n"); 941 + return -EINVAL; 942 + } 943 + 940 944 rbo = gem_to_amdgpu_bo(obj); 941 945 adev = amdgpu_ttm_adev(rbo->tbo.bdev); 942 - 943 946 r = amdgpu_bo_reserve(rbo, true); 944 947 if (r) { 945 948 dev_err(adev->dev, "fail to reserve bo (%d)\n", r);