gpu: host1x: Fix potential out-of-bounds access
authorThierry Reding <treding@nvidia.com>
Thu, 9 Mar 2017 19:04:57 +0000 (20:04 +0100)
committerThierry Reding <treding@nvidia.com>
Tue, 4 Apr 2017 17:18:47 +0000 (19:18 +0200)
The check for valid syncpoint IDs is off by one. While at it, rewrite
the check to make it more easily understandable.

Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/gpu/host1x/syncpt.c

index 25c11a85050baf3df430336d87a87dd1af2ef894..0ac026cdc30cea06c4d99e64167615512291ff8d 100644 (file)
@@ -484,7 +484,7 @@ unsigned int host1x_syncpt_nb_mlocks(struct host1x *host)
 
 struct host1x_syncpt *host1x_syncpt_get(struct host1x *host, unsigned int id)
 {
-       if (host->info->nb_pts < id)
+       if (id >= host->info->nb_pts)
                return NULL;
 
        return host->syncpt + id;