Linux-Rockchip Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/rockchip: gem: check drm_gem_object_init() return value
@ 2026-05-06  0:57 邱晓金
  0 siblings, 0 replies; only message in thread
From: 邱晓金 @ 2026-05-06  0:57 UTC (permalink / raw)
  To: hjc, heiko, andy.yan
  Cc: dri-devel, airlied, simona, maarten.lankhorst, mripard,
	tzimmermann, linux-rockchip, 邱晓金

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-05-06  0:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-06  0:57 [PATCH] drm/rockchip: gem: check drm_gem_object_init() return value 邱晓金

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox