Mesa (main): util/ra: Fix numeric overflow during bitset allocation
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Dec 19 21:57:48 UTC 2021
Module: Mesa
Branch: main
Commit: e9cc1633a225cfcc7d3313e8755b95b2693301b3
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e9cc1633a225cfcc7d3313e8755b95b2693301b3
Author: Kostiantyn Lazukin <konstantin.lazukin at globallogic.com>
Date: Thu Dec 16 13:23:49 2021 +0200
util/ra: Fix numeric overflow during bitset allocation
Reviewed-by: Emma Anholt <emma at anholt.net>
Signed-off-by: Kostiantyn Lazukin <kostiantyn.lazukin at globallogic.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5752
Fixes: d4a4cd20d52 ("util/ra: use adjacency matrix for undirected graph")
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14224>
---
src/util/register_allocate.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/util/register_allocate.c b/src/util/register_allocate.c
index dd02b8b12cc..ac9feb15c84 100644
--- a/src/util/register_allocate.c
+++ b/src/util/register_allocate.c
@@ -472,13 +472,13 @@ ra_set_deserialize(void *mem_ctx, struct blob_reader *blob)
return regs;
}
-static unsigned
-ra_get_num_adjacency_bits(unsigned int n)
+static uint64_t
+ra_get_num_adjacency_bits(uint64_t n)
{
return (n * (n - 1)) / 2;
}
-static unsigned
+static uint64_t
ra_get_adjacency_bit_index(unsigned n1, unsigned n2)
{
assert(n1 != n2);
@@ -490,7 +490,7 @@ ra_get_adjacency_bit_index(unsigned n1, unsigned n2)
static bool
ra_test_adjacency_bit(struct ra_graph *g, unsigned n1, unsigned n2)
{
- unsigned index = ra_get_adjacency_bit_index(n1, n2);
+ uint64_t index = ra_get_adjacency_bit_index(n1, n2);
return BITSET_TEST(g->adjacency, index);
}
More information about the mesa-commit
mailing list