linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/rockchip: Don't allow zero sized gem buffer
@ 2017-05-23  6:39 Jeffy Chen
  2017-05-25 15:30 ` Sean Paul
  0 siblings, 1 reply; 6+ messages in thread
From: Jeffy Chen @ 2017-05-23  6:39 UTC (permalink / raw)
  To: linux-kernel
  Cc: seanpaul, tfiga, Jeffy Chen, Mark Yao, Heiko Stuebner, dri-devel,
	linux-rockchip, David Airlie, linux-arm-kernel

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-05-26 13:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-23  6:39 [PATCH] drm/rockchip: Don't allow zero sized gem buffer Jeffy Chen
2017-05-25 15:30 ` Sean Paul
2017-05-26  2:30   ` jeffy
2017-05-26  5:52     ` Christoph Hellwig
2017-05-26  6:50       ` Daniel Vetter
2017-05-26 13:49     ` Sean Paul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).