summaryrefslogtreecommitdiff
path: root/tools/lib/python/kdoc/python_version.py
diff options
context:
space:
mode:
authorYishai Hadas <yishaih@nvidia.com>2026-09-15 18:33:29 +0300
committerLeon Romanovsky <leon@kernel.org>2026-09-22 09:14:44 -0400
commitc5fe428bb23edc833ebcf99de0ea92c1625a3c7b (patch)
tree00333e7bf78f29e026083342ae3e0613ec81f6ea /tools/lib/python/kdoc/python_version.py
parentc6aa5feb52106664df44ef3c8c1da48f703ef8f0 (diff)
RDMA/mlx4: Use unsigned comparison in the CQ cleanup loop
__mlx4_ib_cq_clean() sweeps the CQ backwards from the producer index down to the consumer index: while ((int) --prod_index - (int) cq->mcq.cons_index >= 0) Both indexes are free running u32 counters, so the comparison has to be done modulo 2^32. Casting each operand to int and subtracting does not do that: the subtraction overflows whenever the two indexes straddle 2^31, which is undefined behaviour, and a compiler that assumes signed overflow cannot occur is free to discard the subtraction and fold the expression into a plain signed comparison. That comparison is not wraparound safe. The kernel is built with -fno-strict-overflow, so gcc and clang both retain the subtraction today and the generated code is unaffected; there is no known user-visible impact from the current code. Still, correctness here shouldn't depend on that build flag. Replace the loop with a plain unsigned equality check instead: while (prod_index != cq->mcq.cons_index) { --prod_index; ... The preceding forward scan starts prod_index at cons_index and stops no later than cons_index + cq->ibcq.cqe, so the two indexes are at most cq->ibcq.cqe apart. Decrementing prod_index reaches cons_index in exactly that many iterations regardless of whether either counter has wrapped, because the loop no longer compares magnitudes at all. Signed-off-by: Yishai Hadas <yishaih@nvidia.com> Signed-off-by: Edward Srouji <edwards@nvidia.com> Link: https://patch.msgid.link/20260915-fix-cq-cleanup-v1-2-e991944cf898@nvidia.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
Diffstat (limited to 'tools/lib/python/kdoc/python_version.py')
0 files changed, 0 insertions, 0 deletions