lkml.org 
[lkml]   [2017]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] drm/rockchip: Don't allow zero sized gem buffer
Date
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

\
 
 \ /
  Last update: 2017-05-26 04:18    [W:0.595 / U:0.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site