[PATCH v2] drm/rockchip: Don't allow zero sized gem buffer
From: Jeffy Chen
Date: Thu May 25 2017 - 22:16:45 EST
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@xxxxxxxxxxxxxx>
---
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