c0853e1
From 30772942cc1095c3129eecfa182e2c568e566b9d Mon Sep 17 00:00:00 2001
c0853e1
From: Dan Carpenter <dan.carpenter@oracle.com>
c0853e1
Date: Thu, 13 Oct 2016 11:54:31 +0300
c0853e1
Subject: [PATCH] drm/vc4: Fix a couple error codes in vc4_cl_lookup_bos()
c0853e1
c0853e1
If the allocation fails the current code returns success.  If
c0853e1
copy_from_user() fails it returns the number of bytes remaining instead
c0853e1
of -EFAULT.
c0853e1
c0853e1
Fixes: d5b1a78a772f ("drm/vc4: Add support for drawing 3D frames.")
c0853e1
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
c0853e1
Reviewed-by: Eric Anholt <eric@anholt.net>
c0853e1
---
c0853e1
 drivers/gpu/drm/vc4/vc4_gem.c | 9 +++++----
c0853e1
 1 file changed, 5 insertions(+), 4 deletions(-)
c0853e1
c0853e1
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
c0853e1
index ae1609e..4050540 100644
c0853e1
--- a/drivers/gpu/drm/vc4/vc4_gem.c
c0853e1
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
c0853e1
@@ -548,14 +548,15 @@ vc4_cl_lookup_bos(struct drm_device *dev,
c0853e1
 
c0853e1
 	handles = drm_malloc_ab(exec->bo_count, sizeof(uint32_t));
c0853e1
 	if (!handles) {
c0853e1
+		ret = -ENOMEM;
c0853e1
 		DRM_ERROR("Failed to allocate incoming GEM handles\n");
c0853e1
 		goto fail;
c0853e1
 	}
c0853e1
 
c0853e1
-	ret = copy_from_user(handles,
c0853e1
-			     (void __user *)(uintptr_t)args->bo_handles,
c0853e1
-			     exec->bo_count * sizeof(uint32_t));
c0853e1
-	if (ret) {
c0853e1
+	if (copy_from_user(handles,
c0853e1
+			   (void __user *)(uintptr_t)args->bo_handles,
c0853e1
+			   exec->bo_count * sizeof(uint32_t))) {
c0853e1
+		ret = -EFAULT;
c0853e1
 		DRM_ERROR("Failed to copy in GEM handles\n");
c0853e1
 		goto fail;
c0853e1
 	}
c0853e1
-- 
c0853e1
2.9.3
c0853e1