Skip to contentSkip to conversation

drm/rockchip: Don't allow zero sized gem buffer

PATCH New Jeffy Chen 1 participant 1 message May 26, 2017

Subsystems (4)
lore
Share & tools
lore

Jeffy Chen

author
#0 lore raw

PATCH v2 1/1 drm/rockchip: Don't allow zero sized gem buffer

Currently we only call this from dumb_create, which would guarantee the size is non-zero.

But it would be harmless to add a sanity check for it for further extension.

This is much the same as:
1a5dff5 drm/msm: Don't allow zero sized buffer objects

v2: Rewrite commit message.

---

Changes in v2:
Rewrite commit message.

 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/rockchip/rockchip_drm_gem.c +5 -0
index df9e570..8917922 100644
@@ -315,6 +315,11 @@ struct rockchip_gem_object *
 	struct drm_gem_object *obj;
 	int ret;
 
+	if (!size) {
+		DRM_ERROR("gem buffer size is zero\n");
+		return ERR_PTR(-EINVAL);
+	}
+
 	size = round_up(size, PAGE_SIZE);
 
 	rk_obj = kzalloc(sizeof(*rk_obj), GFP_KERNEL);
Signature · 1 line
2.1.4