drm/gem: Warn on trying to use a non-existing framebuffer plane
authorThomas Zimmermann <tzimmermann@suse.de>
Tue, 17 May 2022 11:33:27 +0000 (13:33 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Thu, 19 May 2022 17:25:23 +0000 (19:25 +0200)
Warn if callers of drm_gem_fb_get_obj() try to use a GEM buffer for
a non-existing or unset plane.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Tested-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220517113327.26919-6-tzimmermann@suse.de
drivers/gpu/drm/drm_gem_framebuffer_helper.c

index 6d3c26efdeeb6f9e8c26c91395a04087c6c67396..61339a9cd01011927b702f8648dc2f8ef49dd990 100644 (file)
@@ -53,7 +53,11 @@ MODULE_IMPORT_NS(DMA_BUF);
 struct drm_gem_object *drm_gem_fb_get_obj(struct drm_framebuffer *fb,
                                          unsigned int plane)
 {
-       if (plane >= ARRAY_SIZE(fb->obj))
+       struct drm_device *dev = fb->dev;
+
+       if (drm_WARN_ON_ONCE(dev, plane >= ARRAY_SIZE(fb->obj)))
+               return NULL;
+       else if (drm_WARN_ON_ONCE(dev, !fb->obj[plane]))
                return NULL;
 
        return fb->obj[plane];