pan/midgard: Bounds check lcra_restrict_range
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 23 Dec 2019 20:49:18 +0000 (15:49 -0500)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 24 Dec 2019 23:46:22 +0000 (23:46 +0000)
We may call it with sentinel values (~0 in particular) corresponding to
unused arguments; ignore these.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/lcra.c

index a280a744b924e6924ec5a8c89a07e1088655ace0..28f9a735a4466e5773ea7f3c6d5d9d5828eb00b9 100644 (file)
@@ -101,7 +101,7 @@ lcra_set_disjoint_class(struct lcra_state *l, unsigned c1, unsigned c2)
 void
 lcra_restrict_range(struct lcra_state *l, unsigned node, unsigned len)
 {
-        if (l->alignment[node])
+        if (node < l->node_count && l->alignment[node])
                 l->modulus[node] = DIV_ROUND_UP(l->bound - len + 1, 1 << (l->alignment[node] - 1));
 }