Skip to content

Commit

Permalink
drm/tegra: return -EFAULT if copy_from_user() fails
Browse files Browse the repository at this point in the history
copy_from_user() returns the number of bytes remaining if it fails, but
we want to return -EFAULT here.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
  • Loading branch information
Dan Carpenter authored and Thierry Reding committed Dec 3, 2013
1 parent d24b289 commit 9a99160
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions drivers/gpu/drm/tegra/drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,10 @@ int tegra_drm_submit(struct tegra_drm_context *context,
struct drm_tegra_cmdbuf cmdbuf;
struct host1x_bo *bo;

err = copy_from_user(&cmdbuf, cmdbufs, sizeof(cmdbuf));
if (err)
if (copy_from_user(&cmdbuf, cmdbufs, sizeof(cmdbuf))) {
err = -EFAULT;
goto fail;
}

bo = host1x_bo_lookup(drm, file, cmdbuf.handle);
if (!bo) {
Expand All @@ -178,10 +179,11 @@ int tegra_drm_submit(struct tegra_drm_context *context,
cmdbufs++;
}

err = copy_from_user(job->relocarray, relocs,
sizeof(*relocs) * num_relocs);
if (err)
if (copy_from_user(job->relocarray, relocs,
sizeof(*relocs) * num_relocs)) {
err = -EFAULT;
goto fail;
}

while (num_relocs--) {
struct host1x_reloc *reloc = &job->relocarray[num_relocs];
Expand All @@ -199,15 +201,17 @@ int tegra_drm_submit(struct tegra_drm_context *context,
}
}

err = copy_from_user(job->waitchk, waitchks,
sizeof(*waitchks) * num_waitchks);
if (err)
if (copy_from_user(job->waitchk, waitchks,
sizeof(*waitchks) * num_waitchks)) {
err = -EFAULT;
goto fail;
}

err = copy_from_user(&syncpt, (void __user *)(uintptr_t)args->syncpts,
sizeof(syncpt));
if (err)
if (copy_from_user(&syncpt, (void __user *)(uintptr_t)args->syncpts,
sizeof(syncpt))) {
err = -EFAULT;
goto fail;
}

job->is_addr_reg = context->client->ops->is_addr_reg;
job->syncpt_incrs = syncpt.incrs;
Expand Down

0 comments on commit 9a99160

Please sign in to comment.