]> git.karo-electronics.de Git - linux-beck.git/commitdiff
drm/vc4: Fix a couple error codes in vc4_cl_lookup_bos()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 13 Oct 2016 08:54:31 +0000 (11:54 +0300)
committerEric Anholt <eric@anholt.net>
Mon, 17 Oct 2016 17:00:11 +0000 (10:00 -0700)
If the allocation fails the current code returns success.  If
copy_from_user() fails it returns the number of bytes remaining instead
of -EFAULT.

Fixes: d5b1a78a772f ("drm/vc4: Add support for drawing 3D frames.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
drivers/gpu/drm/vc4/vc4_gem.c

index 47a095f392f8a7b5443227933c78b500a4c7137f..303f23c962206836d8c95786ad835d7625e10ee8 100644 (file)
@@ -544,14 +544,15 @@ vc4_cl_lookup_bos(struct drm_device *dev,
 
        handles = drm_malloc_ab(exec->bo_count, sizeof(uint32_t));
        if (!handles) {
+               ret = -ENOMEM;
                DRM_ERROR("Failed to allocate incoming GEM handles\n");
                goto fail;
        }
 
-       ret = copy_from_user(handles,
-                            (void __user *)(uintptr_t)args->bo_handles,
-                            exec->bo_count * sizeof(uint32_t));
-       if (ret) {
+       if (copy_from_user(handles,
+                          (void __user *)(uintptr_t)args->bo_handles,
+                          exec->bo_count * sizeof(uint32_t))) {
+               ret = -EFAULT;
                DRM_ERROR("Failed to copy in GEM handles\n");
                goto fail;
        }