Commit c730a84a authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman

drm/vc4: Fix a couple error codes in vc4_cl_lookup_bos()

commit b2cdeb19 upstream.

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: d5b1a78a ("drm/vc4: Add support for drawing 3D frames.")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarEric Anholt <eric@anholt.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a63bb198
...@@ -544,14 +544,15 @@ vc4_cl_lookup_bos(struct drm_device *dev, ...@@ -544,14 +544,15 @@ vc4_cl_lookup_bos(struct drm_device *dev,
handles = drm_malloc_ab(exec->bo_count, sizeof(uint32_t)); handles = drm_malloc_ab(exec->bo_count, sizeof(uint32_t));
if (!handles) { if (!handles) {
ret = -ENOMEM;
DRM_ERROR("Failed to allocate incoming GEM handles\n"); DRM_ERROR("Failed to allocate incoming GEM handles\n");
goto fail; goto fail;
} }
ret = copy_from_user(handles, if (copy_from_user(handles,
(void __user *)(uintptr_t)args->bo_handles, (void __user *)(uintptr_t)args->bo_handles,
exec->bo_count * sizeof(uint32_t)); exec->bo_count * sizeof(uint32_t))) {
if (ret) { ret = -EFAULT;
DRM_ERROR("Failed to copy in GEM handles\n"); DRM_ERROR("Failed to copy in GEM handles\n");
goto fail; goto fail;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment