All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: daniel@ffwll.ch, airlied@linux.ie, mripard@kernel.org,
	maarten.lankhorst@linux.intel.com, noralf@tronnes.org,
	christian.koenig@amd.com
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: [PATCH 4/4] drm/gem: Warn on trying to use a non-existing framebuffer plane
Date: Mon,  9 May 2022 10:16:02 +0200	[thread overview]
Message-ID: <20220509081602.474-5-tzimmermann@suse.de> (raw)
In-Reply-To: <20220509081602.474-1-tzimmermann@suse.de>

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>
---
 drivers/gpu/drm/drm_gem_framebuffer_helper.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_gem_framebuffer_helper.c b/drivers/gpu/drm/drm_gem_framebuffer_helper.c
index 09e90e19cd93..291f9ae4359d 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];
-- 
2.36.0


  parent reply	other threads:[~2022-05-09  8:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09  8:15 [PATCH 0/4] drm: Ignore non-existing color planes in helpers Thomas Zimmermann
2022-05-09  8:15 ` [PATCH 1/4] drm/gem: Share code between drm_gem_fb_{begin, end}_cpu_access() Thomas Zimmermann
2022-05-16 13:00   ` Javier Martinez Canillas
2022-05-17 10:14     ` Thomas Zimmermann
2022-05-09  8:16 ` [PATCH 2/4] drm/gem: Ignore color planes that are unused by framebuffer format Thomas Zimmermann
2022-05-16 13:20   ` Javier Martinez Canillas
2022-05-09  8:16 ` [PATCH 3/4] drm/gem-vram: Ignore " Thomas Zimmermann
2022-05-16 13:34   ` Javier Martinez Canillas
2022-05-17 10:15     ` Thomas Zimmermann
2022-05-09  8:16 ` Thomas Zimmermann [this message]
2022-05-16 13:35   ` [PATCH 4/4] drm/gem: Warn on trying to use a non-existing framebuffer plane Javier Martinez Canillas
2022-05-16 11:46 ` [PATCH 0/4] drm: Ignore non-existing color planes in helpers Thomas Zimmermann
2022-05-16 13:29 ` Noralf Trønnes
2022-05-13 13:35 [PATCH 4/4] drm/gem: Warn on trying to use a non-existing framebuffer plane kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220509081602.474-5-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@linux.ie \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=noralf@tronnes.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.