dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [patch] drm/vc4: Return -EFAULT on copy_from_user() failure
@ 2016-03-08 12:09 Dan Carpenter
  2016-03-14  0:10 ` Eric Anholt
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2016-03-08 12:09 UTC (permalink / raw)
  To: David Airlie, Eric Anholt
  Cc: Daniel Vetter, Luis R. Rodriguez, kernel-janitors, linux-kernel,
	dri-devel, Andrew Morton

The copy_from_user() function returns the number of bytes not copied but
we want to return a negative error code.

Fixes: 463873d57014 ('drm/vc4: Add an API for creating GPU shaders in GEM BOs.')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c
index 034ef2d..9807bc9 100644
--- a/drivers/gpu/drm/vc4/vc4_bo.c
+++ b/drivers/gpu/drm/vc4/vc4_bo.c
@@ -498,11 +498,12 @@ vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data,
 	if (IS_ERR(bo))
 		return PTR_ERR(bo);
 
-	ret = copy_from_user(bo->base.vaddr,
+	if (copy_from_user(bo->base.vaddr,
 			     (void __user *)(uintptr_t)args->data,
-			     args->size);
-	if (ret != 0)
+			     args->size)) {
+		ret = -EFAULT;
 		goto fail;
+	}
 	/* Clear the rest of the memory from allocating from the BO
 	 * cache.
 	 */
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [patch] drm/vc4: Return -EFAULT on copy_from_user() failure
  2016-03-08 12:09 [patch] drm/vc4: Return -EFAULT on copy_from_user() failure Dan Carpenter
@ 2016-03-14  0:10 ` Eric Anholt
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Anholt @ 2016-03-14  0:10 UTC (permalink / raw)
  To: Dan Carpenter, David Airlie
  Cc: Daniel Vetter, Luis R. Rodriguez, kernel-janitors, linux-kernel,
	dri-devel, Andrew Morton


[-- Attachment #1.1: Type: text/plain, Size: 329 bytes --]

Dan Carpenter <dan.carpenter@oracle.com> writes:

> The copy_from_user() function returns the number of bytes not copied but
> we want to return a negative error code.
>
> Fixes: 463873d57014 ('drm/vc4: Add an API for creating GPU shaders in GEM BOs.')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Pulled.  Thanks!

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2016-03-14  1:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-08 12:09 [patch] drm/vc4: Return -EFAULT on copy_from_user() failure Dan Carpenter
2016-03-14  0:10 ` Eric Anholt

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).