summaryrefslogtreecommitdiff
path: root/drivers/gpu
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2016-08-18 22:35:14 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2016-08-19 10:58:55 +0200
commit7ad61e6b4a79c5057eeb2d6062b0021e33ddc9f6 (patch)
treea53f741e99eefbec63bf1b95b49625bea16df286 /drivers/gpu
parenta6e3918bcdb1253083f962d747ec699bdb4bacd9 (diff)
virtio-gpu: Use memdup_user() rather than duplicating its implementation
Reuse existing functionality from memdup_user() instead of keeping duplicate source code. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/401e68fc-5515-7a7a-be2e-503dee676b34@users.sourceforge.net
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/virtio/virtgpu_ioctl.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index c046903cb47b..512e7cddcbae 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
@@ -152,15 +152,10 @@ static int virtio_gpu_execbuffer(struct drm_device *dev,
if (ret)
goto out_free;
- buf = kmalloc(exbuf->size, GFP_KERNEL);
- if (!buf) {
- ret = -ENOMEM;
- goto out_unresv;
- }
- if (copy_from_user(buf, (void __user *)(uintptr_t)exbuf->command,
- exbuf->size)) {
- kfree(buf);
- ret = -EFAULT;
+ buf = memdup_user((void __user *)(uintptr_t)exbuf->command,
+ exbuf->size);
+ if (IS_ERR(buf)) {
+ ret = PTR_ERR(buf);
goto out_unresv;
}
virtio_gpu_cmd_submit(vgdev, buf, exbuf->size,