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:31 +0300
committerLeon Romanovsky <leon@kernel.org>2026-09-22 09:14:44 -0400
commitebb65190349537933a796ee662d05d0464bd4066 (patch)
treea315ed3c1ffbd1501262f986c4d9efe18dc0a2ea /tools/lib/python/kdoc/python_version.py
parentb934024d3aafb9de938a6eb424bbb485e2053450 (diff)
RDMA/hns: Use unsigned comparison in the CQ cleanup loop
__hns_roce_v2_cq_clean() sweeps the CQ backwards from the producer index down to the consumer index: while ((int) --prod_index - (int) hr_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 != hr_cq->cons_index) { --prod_index; ... The preceding forward scan starts prod_index at cons_index and advances it only while get_sw_cqe_v2() still reports a software owned entry, so the two indexes stay within one CQ's worth of entries. 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-4-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