diff --git a/fabtests/common/shared.c b/fabtests/common/shared.c index 98a31a3f7e1..21e244eb209 100644 --- a/fabtests/common/shared.c +++ b/fabtests/common/shared.c @@ -2767,6 +2767,12 @@ static int ft_spin_for_comp(struct fid_cq *cq, uint64_t *cur, if (timeout >= 0) clock_gettime(CLOCK_MONOTONIC, &a); + /* + * Callers must ensure *cur < total; calling with *cur >= total + * is a bug because the do...while loop always executes at least + * once and can increment *cur causing an underflow in the + * loop condition. + */ do { ret = fi_cq_read(cq, &comp, 1); if (ret > 0) {