If the function rte_combine64ms1b() returns the maximum possible uint64_t
value, it will result in an overflow.
To avoid this, add a check.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 7253e3d2a5 ("bitops: move bit count functions")
Cc: [email protected]
Signed-off-by: Alexey Simakov <[email protected]>
Signed-off-by: Mark Bulatov <[email protected]>
---
lib/eal/include/rte_bitops.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/eal/include/rte_bitops.h b/lib/eal/include/rte_bitops.h
index 45255b68aa..d2ed0c3c61 100644
--- a/lib/eal/include/rte_bitops.h
+++ b/lib/eal/include/rte_bitops.h
@@ -1307,6 +1307,9 @@ rte_align64pow2(uint64_t v)
v--;
v = rte_combine64ms1b(v);
+ if (v == UINT64_MAX)
+ v--;
+
return v + 1;
}
--
2.39.5