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:30 +0300
committerLeon Romanovsky <leon@kernel.org>2026-09-22 09:14:44 -0400
commitb934024d3aafb9de938a6eb424bbb485e2053450 (patch)
tree961a8aa537bd95b6a2648303361bb1dbdfbaab17 /tools/lib/python/kdoc/python_version.py
parentc5fe428bb23edc833ebcf99de0ea92c1625a3c7b (diff)
RDMA/mthca: Use unsigned comparison in the CQ cleanup loop
mthca_cq_clean() sweeps the CQ backwards from the producer index down to the consumer index: while ((int) --prod_index - (int) cq->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->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-3-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