Skip to content

Commit 73dd0ad

Browse files
Ma Kealexdeucher
authored andcommitted
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: 5d945cb ("drm/amd/display: Create a file dedicated to planes") Signed-off-by: Ma Ke <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 4416377 commit 73dd0ad

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <drm/drm_blend.h>
2929
#include <drm/drm_gem_atomic_helper.h>
3030
#include <drm/drm_plane_helper.h>
31+
#include <drm/drm_gem_framebuffer_helper.h>
3132
#include <drm/drm_fourcc.h>
3233

3334
#include "amdgpu.h"
@@ -935,10 +936,14 @@ static int amdgpu_dm_plane_helper_prepare_fb(struct drm_plane *plane,
935936
}
936937

937938
afb = to_amdgpu_framebuffer(new_state->fb);
938-
obj = new_state->fb->obj[0];
939+
obj = drm_gem_fb_get_obj(new_state->fb, 0);
940+
if (!obj) {
941+
DRM_ERROR("Failed to get obj from framebuffer\n");
942+
return -EINVAL;
943+
}
944+
939945
rbo = gem_to_amdgpu_bo(obj);
940946
adev = amdgpu_ttm_adev(rbo->tbo.bdev);
941-
942947
r = amdgpu_bo_reserve(rbo, true);
943948
if (r) {
944949
dev_err(adev->dev, "fail to reserve bo (%d)\n", r);

0 commit comments

Comments
 (0)