Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1647687 > unrolled thread
| Started by | Jeffy Chen <jeffy.chen@rock-chips.com> |
|---|---|
| First post | 2017-05-23 08:50 +0200 |
| Last post | 2017-05-23 08:50 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH] drm/rockchip: Don't allow zero sized gem buffer Jeffy Chen <jeffy.chen@rock-chips.com> - 2017-05-23 08:50 +0200
| From | Jeffy Chen <jeffy.chen@rock-chips.com> |
|---|---|
| Date | 2017-05-23 08:50 +0200 |
| Subject | [PATCH] drm/rockchip: Don't allow zero sized gem buffer |
| Message-ID | <tKbNM-7U4-17@gated-at.bofh.it> |
The system would crash when trying to alloc zero sized gem buffer:
[ 6.712435] Unable to handle kernel NULL pointer dereference at virtual address 00000010 <--ZERO_SIZE_PTR
...
[ 6.757502] PC is at sg_alloc_table_from_pages+0x170/0x1ec
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
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 top | Article view | linux.kernel
csiph-web