drm/amd/display: avoid using null object of framebuffer
authorjsg <jsg@openbsd.org>
Thu, 5 Sep 2024 04:31:26 +0000 (04:31 +0000)
committerjsg <jsg@openbsd.org>
Thu, 5 Sep 2024 04:31:26 +0000 (04:31 +0000)
From Ma Ke
f6f5e39a3fe7cbdba190f42b28b40bdff03c8cf0 in linux-6.6.y/6.6.49
3b9a33235c773c7a3768060cf1d2cf8a9153bc37 in mainline linux

sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c

index cc74dd6..fa9f53b 100644 (file)
@@ -28,6 +28,7 @@
 #include <drm/drm_blend.h>
 #include <drm/drm_gem_atomic_helper.h>
 #include <drm/drm_plane_helper.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 #include <drm/drm_fourcc.h>
 
 #include "amdgpu.h"
@@ -848,10 +849,14 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
        }
 
        afb = to_amdgpu_framebuffer(new_state->fb);
-       obj = new_state->fb->obj[0];
+       obj = drm_gem_fb_get_obj(new_state->fb, 0);
+       if (!obj) {
+               DRM_ERROR("Failed to get obj from framebuffer\n");
+               return -EINVAL;
+       }
+
        rbo = gem_to_amdgpu_bo(obj);
        adev = amdgpu_ttm_adev(rbo->tbo.bdev);
-
        r = amdgpu_bo_reserve(rbo, true);
        if (r) {
                dev_err(adev->dev, "fail to reserve bo (%d)\n", r);