Commit 21c42da1 authored by Dan Carpenter's avatar Dan Carpenter Committed by Rob Clark

drm/msm: return -EFAULT if copy_from_user() fails

copy_from_user_inatomic() is actually a local function that returns
-EFAULT or positive values on error.  Otherwise copy_from_user() returns
the number of bytes remaining to be copied.  We want to return -EFAULT
here.

I removed an unlikely() because we just did a copy_from_user()
so I don't think it can possibly make a difference.
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
parent f079f6d9
...@@ -95,13 +95,13 @@ static int submit_lookup_objects(struct msm_gem_submit *submit, ...@@ -95,13 +95,13 @@ static int submit_lookup_objects(struct msm_gem_submit *submit,
*/ */
submit->bos[i].flags = 0; submit->bos[i].flags = 0;
ret = copy_from_user_inatomic(&submit_bo, userptr, sizeof(submit_bo)); if (copy_from_user_inatomic(&submit_bo, userptr, sizeof(submit_bo))) {
if (unlikely(ret)) {
pagefault_enable(); pagefault_enable();
spin_unlock(&file->table_lock); spin_unlock(&file->table_lock);
ret = copy_from_user(&submit_bo, userptr, sizeof(submit_bo)); if (copy_from_user(&submit_bo, userptr, sizeof(submit_bo))) {
if (ret) ret = -EFAULT;
goto out; goto out;
}
spin_lock(&file->table_lock); spin_lock(&file->table_lock);
pagefault_disable(); pagefault_disable();
} }
...@@ -317,9 +317,10 @@ static int submit_reloc(struct msm_gem_submit *submit, struct msm_gem_object *ob ...@@ -317,9 +317,10 @@ static int submit_reloc(struct msm_gem_submit *submit, struct msm_gem_object *ob
uint64_t iova; uint64_t iova;
bool valid; bool valid;
ret = copy_from_user(&submit_reloc, userptr, sizeof(submit_reloc)); if (copy_from_user(&submit_reloc, userptr, sizeof(submit_reloc))) {
if (ret) ret = -EFAULT;
goto out; goto out;
}
if (submit_reloc.submit_offset % 4) { if (submit_reloc.submit_offset % 4) {
DRM_ERROR("non-aligned reloc offset: %u\n", DRM_ERROR("non-aligned reloc offset: %u\n",
......
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