Linux-Rockchip Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: 邱晓金 <qiuxiaojin@qs-tech.com>
To: hjc <hjc@rock-chips.com>,  heiko <heiko@sntech.de>,
	 andy.yan <andy.yan@rock-chips.com>
Cc: dri-devel <dri-devel@lists.freedesktop.org>,
	airlied <airlied@gmail.com>, simona <simona@ffwll.ch>,
	"maarten.lankhorst" <maarten.lankhorst@linux.intel.com>,
	mripard <mripard@kernel.org>, tzimmermann <tzimmermann@suse.de>,
	linux-rockchip <linux-rockchip@lists.infradead.org>,
	邱晓金 <qiuxiaojin@cvte.com>
Subject: [PATCH] drm/rockchip: gem: check drm_gem_object_init() return value
Date: Wed, 6 May 2026 08:57:22 +0800	[thread overview]
Message-ID: <A381993FF0E67CFE+202605060857210496809@qs-tech.com> (raw)

From ab8b1592209438a04c635d4c6c40c398230c1ba7 Mon Sep 17 00:00:00 2001
From: Qiu Xiaojin <qiuxiaojin@qs-tech.com>
Date: Wed, 6 May 2026 08:52:45 +0800
Subject: [PATCH] drm/rockchip: gem: check drm_gem_object_init() return value

rockchip_gem_alloc_object() currently ignores the return value of

drm_gem_object_init(). If initialization fails, the function can
return an incompletely initialized GEM object.

Handle the failure by freeing the allocated object and returning
ERR_PTR(ret).

Fixes: 38f993b7c59e ("drm/rockchip: Do not use DMA mapping API if attached to IOMMU domain")
Signed-off-by: Qiu Xiaojin <qiuxiaojin@qs-tech.com>
---
 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index 09d14a072d27..ef16b1fabec3 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -286,6 +286,7 @@ static struct rockchip_gem_object *
 {
 	struct rockchip_gem_object *rk_obj;
 	struct drm_gem_object *obj;
+	int ret;
 
 	size = round_up(size, PAGE_SIZE);
 
@@ -297,7 +298,11 @@ static struct rockchip_gem_object *
 
 	obj->funcs = &rockchip_gem_object_funcs;
 
-	drm_gem_object_init(drm, obj, size);
+	ret = drm_gem_object_init(drm, obj, size);
+	if (ret) {
+		kfree(rk_obj);
+		return ERR_PTR(ret);
+	}
 
 	return rk_obj;
 }
-- 
2.34.1








--------------



Qiu Xiaojin


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

                 reply	other threads:[~2026-05-06  0:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=A381993FF0E67CFE+202605060857210496809@qs-tech.com \
    --to=qiuxiaojin@qs-tech.com \
    --cc=airlied@gmail.com \
    --cc=andy.yan@rock-chips.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=heiko@sntech.de \
    --cc=hjc@rock-chips.com \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=qiuxiaojin@cvte.com \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox