* [PATCH] virtio-gpu: Use memdup_user() rather than duplicating its implementation
@ 2016-08-18 20:42 ` SF Markus Elfring
0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2016-08-18 20:42 UTC (permalink / raw)
To: dri-devel, virtualization, David Airlie, Gerd Hoffmann
Cc: LKML, kernel-janitors, Julia Lawall
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/gpu/drm/virtio/virtgpu_ioctl.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index c046903..512e7cd 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,
--
2.9.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] virtio-gpu: Use memdup_user() rather than duplicating its implementation
@ 2016-08-18 20:42 ` SF Markus Elfring
0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2016-08-18 20:42 UTC (permalink / raw)
To: dri-devel, virtualization, David Airlie, Gerd Hoffmann
Cc: Julia Lawall, kernel-janitors, LKML
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/gpu/drm/virtio/virtgpu_ioctl.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index c046903..512e7cd 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,
--
2.9.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] virtio-gpu: Use memdup_user() rather than duplicating its implementation
@ 2016-08-18 20:42 ` SF Markus Elfring
0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2016-08-18 20:42 UTC (permalink / raw)
To: dri-devel, virtualization, David Airlie, Gerd Hoffmann
Cc: Julia Lawall, kernel-janitors, LKML
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/gpu/drm/virtio/virtgpu_ioctl.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index c046903..512e7cd 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,
--
2.9.3
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] virtio-gpu: Use memdup_user() rather than duplicating its implementation
2016-08-18 20:42 ` SF Markus Elfring
(?)
@ 2016-08-19 7:50 ` Daniel Vetter
-1 siblings, 0 replies; 8+ messages in thread
From: Daniel Vetter @ 2016-08-19 7:50 UTC (permalink / raw)
To: SF Markus Elfring
Cc: dri-devel, virtualization, David Airlie, Gerd Hoffmann,
Julia Lawall, kernel-janitors, LKML
On Thu, Aug 18, 2016 at 10:42:06PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Applied to drm-misc.
-Daniel
> ---
> drivers/gpu/drm/virtio/virtgpu_ioctl.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> index c046903..512e7cd 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,
> --
> 2.9.3
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] virtio-gpu: Use memdup_user() rather than duplicating its implementation
@ 2016-08-19 7:50 ` Daniel Vetter
0 siblings, 0 replies; 8+ messages in thread
From: Daniel Vetter @ 2016-08-19 7:50 UTC (permalink / raw)
To: SF Markus Elfring
Cc: kernel-janitors, LKML, dri-devel, virtualization, Julia Lawall,
Gerd Hoffmann
On Thu, Aug 18, 2016 at 10:42:06PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Applied to drm-misc.
-Daniel
> ---
> drivers/gpu/drm/virtio/virtgpu_ioctl.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> index c046903..512e7cd 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,
> --
> 2.9.3
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] virtio-gpu: Use memdup_user() rather than duplicating its implementation
2016-08-18 20:42 ` SF Markus Elfring
` (2 preceding siblings ...)
(?)
@ 2016-08-19 7:50 ` Daniel Vetter
-1 siblings, 0 replies; 8+ messages in thread
From: Daniel Vetter @ 2016-08-19 7:50 UTC (permalink / raw)
To: SF Markus Elfring
Cc: David Airlie, kernel-janitors, LKML, dri-devel, virtualization,
Julia Lawall
On Thu, Aug 18, 2016 at 10:42:06PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Applied to drm-misc.
-Daniel
> ---
> drivers/gpu/drm/virtio/virtgpu_ioctl.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> index c046903..512e7cd 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,
> --
> 2.9.3
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] virtio-gpu: Use memdup_user() rather than duplicating its implementation
@ 2016-08-19 7:50 ` Daniel Vetter
0 siblings, 0 replies; 8+ messages in thread
From: Daniel Vetter @ 2016-08-19 7:50 UTC (permalink / raw)
To: SF Markus Elfring
Cc: kernel-janitors, LKML, dri-devel, virtualization, Julia Lawall,
Gerd Hoffmann
On Thu, Aug 18, 2016 at 10:42:06PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Applied to drm-misc.
-Daniel
> ---
> drivers/gpu/drm/virtio/virtgpu_ioctl.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
> index c046903..512e7cd 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,
> --
> 2.9.3
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] virtio-gpu: Use memdup_user() rather than duplicating its implementation
@ 2016-08-18 20:42 SF Markus Elfring
0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2016-08-18 20:42 UTC (permalink / raw)
To: dri-devel, virtualization, David Airlie, Gerd Hoffmann
Cc: Julia Lawall, kernel-janitors, LKML
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/gpu/drm/virtio/virtgpu_ioctl.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c
index c046903..512e7cd 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,
--
2.9.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-08-19 7:50 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-18 20:42 [PATCH] virtio-gpu: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-18 20:42 ` SF Markus Elfring
2016-08-18 20:42 ` SF Markus Elfring
2016-08-19 7:50 ` Daniel Vetter
2016-08-19 7:50 ` Daniel Vetter
2016-08-19 7:50 ` Daniel Vetter
2016-08-19 7:50 ` Daniel Vetter
-- strict thread matches above, loose matches on Subject: below --
2016-08-18 20:42 SF Markus Elfring
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.