All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: avoid passing null pointer to memset
@ 2012-10-09 17:50 Rodrigo Vivi
  2012-10-09 18:03 ` Chris Wilson
  2012-10-09 19:56 ` Rodrigo Vivi
  0 siblings, 2 replies; 4+ messages in thread
From: Rodrigo Vivi @ 2012-10-09 17:50 UTC (permalink / raw)
  To: dri-devel

When cmd isn't IOC_IN | IOC_OUT a null "kdata" goes to "memset", which dereferences it.

Signed-off-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>
---
 drivers/gpu/drm/drm_drv.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 1490e76..5945920 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -452,8 +452,16 @@ long drm_ioctl(struct file *filp,
 				retcode = -EFAULT;
 				goto err_i1;
 			}
-		} else
+		} else {
+			if (!kdata) {
+				kdata = kmalloc(usize, GFP_KERNEL);
+		    		if (!kdata) {
+					retcode = -ENOMEM;
+					goto err_i1;
+				}
+			}
 			memset(kdata, 0, usize);
+		}
 
 		if (ioctl->flags & DRM_UNLOCKED)
 			retcode = func(dev, kdata, file_priv);
-- 
1.7.11.4

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

end of thread, other threads:[~2012-10-10 12:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-09 17:50 [PATCH] drm: avoid passing null pointer to memset Rodrigo Vivi
2012-10-09 18:03 ` Chris Wilson
2012-10-09 19:56 ` Rodrigo Vivi
2012-10-10 12:52   ` Chris Wilson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.