From: Thierry Reding Date: Thu, 9 Mar 2017 19:04:57 +0000 (+0100) Subject: gpu: host1x: Fix potential out-of-bounds access X-Git-Tag: v4.12-rc1~87^2^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8cadb01d2c2f520a890d1bc78b45471f21b9b76d;p=thirdparty%2Fkernel%2Flinux.git gpu: host1x: Fix potential out-of-bounds access 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 --- diff --git a/drivers/gpu/host1x/syncpt.c b/drivers/gpu/host1x/syncpt.c index 25c11a85050ba..0ac026cdc30ce 100644 --- a/drivers/gpu/host1x/syncpt.c +++ b/drivers/gpu/host1x/syncpt.c @@ -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;