Commit e0b2ce02 authored by Dmitry Osipenko's avatar Dmitry Osipenko Committed by Thierry Reding

drm/tegra: Check syncpoint ID in the 'submit' IOCTL

In case of invalid syncpoint ID, the host1x_syncpt_get() returns NULL and
none of its users perform a check of the returned pointer later. Let's bail
out until it's too late.
Signed-off-by: default avatarDmitry Osipenko <digetx@gmail.com>
Reviewed-by: default avatarMikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
parent d0fbbdff
...@@ -393,6 +393,8 @@ int tegra_drm_submit(struct tegra_drm_context *context, ...@@ -393,6 +393,8 @@ int tegra_drm_submit(struct tegra_drm_context *context,
struct drm_tegra_waitchk __user *waitchks = struct drm_tegra_waitchk __user *waitchks =
(void __user *)(uintptr_t)args->waitchks; (void __user *)(uintptr_t)args->waitchks;
struct drm_tegra_syncpt syncpt; struct drm_tegra_syncpt syncpt;
struct host1x *host1x = dev_get_drvdata(drm->dev->parent);
struct host1x_syncpt *sp;
struct host1x_job *job; struct host1x_job *job;
int err; int err;
...@@ -522,6 +524,13 @@ int tegra_drm_submit(struct tegra_drm_context *context, ...@@ -522,6 +524,13 @@ int tegra_drm_submit(struct tegra_drm_context *context,
goto fail; goto fail;
} }
/* check whether syncpoint ID is valid */
sp = host1x_syncpt_get(host1x, syncpt.id);
if (!sp) {
err = -ENOENT;
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;
job->syncpt_id = syncpt.id; job->syncpt_id = syncpt.id;
......
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