diff options
author | Thomas Zimmermann | 2022-05-17 13:33:27 +0200 |
---|---|---|
committer | Thomas Zimmermann | 2022-05-19 19:25:23 +0200 |
commit | 4f093a527b0b8f9d3059a4e8376e582fd14cf09e (patch) | |
tree | 5f2657720ba113dc5011ebf4bca1ca878e8cc99d | |
parent | a8d6e127254c48d895c4f6e973ec998fd4a0eff3 (diff) |
drm/gem: Warn on trying to use a non-existing framebuffer plane
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
-rw-r--r-- | drivers/gpu/drm/drm_gem_framebuffer_helper.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_gem_framebuffer_helper.c b/drivers/gpu/drm/drm_gem_framebuffer_helper.c index 6d3c26efdeeb..61339a9cd010 100644 --- a/drivers/gpu/drm/drm_gem_framebuffer_helper.c +++ b/drivers/gpu/drm/drm_gem_framebuffer_helper.c @@ -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]; |