Skip to content

Commit

Permalink
[v1.20.x] util: Fix coverity issue about missing lock
Browse files Browse the repository at this point in the history
All write accesses to `wait->signal` are protected by the lock. The read
access should be protected, too.

Signed-off-by: Jianxin Xiong <[email protected]>
(cherry picked from commit e16f28a)
  • Loading branch information
j-xiong committed Jan 20, 2024
1 parent 555760a commit c10b680
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion prov/util/src/util_wait.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,16 @@ static int util_wait_yield_run(struct fid_wait *wait_fid, int timeout)
wait = container_of(wait_fid, struct util_wait_yield, util_wait.wait_fid);
endtime = ofi_timeout_time(timeout);

while (!wait->signal) {
while (1) {
int signaled;

ofi_mutex_lock(&wait->signal_lock);
signaled = wait->signal;
ofi_mutex_unlock(&wait->signal_lock);

if (signaled)
break;

if (ofi_adjust_timeout(endtime, &timeout))
return -FI_ETIMEDOUT;
ofi_mutex_lock(&wait->util_wait.lock);
Expand Down

0 comments on commit c10b680

Please sign in to comment.