virtio-gpu: Use memdup_user() rather than duplicating its implementation
Subsystems (5)
PATCH 1/1 virtio-gpu: Use memdup_user() rather than duplicating its implementation
From: Markus Elfring <[email protected]>
Date: Thu, 18 Aug 2016 22:35:14 +0200
Reuse existing functionality from memdup_user() instead of keeping duplicate source code.
This issue was detected by using the Coccinelle software.
--- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/virtio/virtgpu_ioctl.c +4 -9
@@ -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,
Signature · 1 line
2.9.3
Daniel Vetter
AppliedQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 18 Aug 2016 22:35:14 +0200Reuse 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 <[email protected]>
Applied to drm-misc.
-Daniel
Quoted 35 lines
--- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)drivers/gpu/drm/virtio/virtgpu_ioctl.c +4
-9@@ -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,Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Daniel Vetter
AppliedQuoted 9 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 18 Aug 2016 22:35:14 +0200Reuse 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 <[email protected]>
Applied to drm-misc.
-Daniel
Quoted 35 lines
--- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)drivers/gpu/drm/virtio/virtgpu_ioctl.c +4
-9@@ -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,Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch