Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1651039

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

From Jeffy Chen <jeffy.chen@rock-chips.com>
Newsgroups linux.kernel
Subject [PATCH v2] drm/rockchip: Don't allow zero sized gem buffer
Date 2017-05-26 04:20 +0200
Message-ID <tLd18-8h5-1@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---

Changes in v2:
Rewrite commit message.

 drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
index df9e570..8917922 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c
@@ -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);
-- 
2.1.4

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH v2] drm/rockchip: Don't allow zero sized gem buffer Jeffy Chen <jeffy.chen@rock-chips.com> - 2017-05-26 04:20 +0200

csiph-web