Commit 9a991600 authored by Dan Carpenter's avatar Dan Carpenter Committed by Thierry Reding

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

copy_from_user() returns the number of bytes remaining if it fails, but
we want to return -EFAULT here.
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
parent d24b2898
...@@ -163,9 +163,10 @@ int tegra_drm_submit(struct tegra_drm_context *context, ...@@ -163,9 +163,10 @@ int tegra_drm_submit(struct tegra_drm_context *context,
struct drm_tegra_cmdbuf cmdbuf; struct drm_tegra_cmdbuf cmdbuf;
struct host1x_bo *bo; struct host1x_bo *bo;
err = copy_from_user(&cmdbuf, cmdbufs, sizeof(cmdbuf)); if (copy_from_user(&cmdbuf, cmdbufs, sizeof(cmdbuf))) {
if (err) err = -EFAULT;
goto fail; goto fail;
}
bo = host1x_bo_lookup(drm, file, cmdbuf.handle); bo = host1x_bo_lookup(drm, file, cmdbuf.handle);
if (!bo) { if (!bo) {
...@@ -178,10 +179,11 @@ int tegra_drm_submit(struct tegra_drm_context *context, ...@@ -178,10 +179,11 @@ int tegra_drm_submit(struct tegra_drm_context *context,
cmdbufs++; cmdbufs++;
} }
err = copy_from_user(job->relocarray, relocs, if (copy_from_user(job->relocarray, relocs,
sizeof(*relocs) * num_relocs); sizeof(*relocs) * num_relocs)) {
if (err) err = -EFAULT;
goto fail; goto fail;
}
while (num_relocs--) { while (num_relocs--) {
struct host1x_reloc *reloc = &job->relocarray[num_relocs]; struct host1x_reloc *reloc = &job->relocarray[num_relocs];
...@@ -199,15 +201,17 @@ int tegra_drm_submit(struct tegra_drm_context *context, ...@@ -199,15 +201,17 @@ int tegra_drm_submit(struct tegra_drm_context *context,
} }
} }
err = copy_from_user(job->waitchk, waitchks, if (copy_from_user(job->waitchk, waitchks,
sizeof(*waitchks) * num_waitchks); sizeof(*waitchks) * num_waitchks)) {
if (err) err = -EFAULT;
goto fail; goto fail;
}
err = copy_from_user(&syncpt, (void __user *)(uintptr_t)args->syncpts, if (copy_from_user(&syncpt, (void __user *)(uintptr_t)args->syncpts,
sizeof(syncpt)); sizeof(syncpt))) {
if (err) err = -EFAULT;
goto fail; goto fail;
}
job->is_addr_reg = context->client->ops->is_addr_reg; job->is_addr_reg = context->client->ops->is_addr_reg;
job->syncpt_incrs = syncpt.incrs; job->syncpt_incrs = syncpt.incrs;
......
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