Skip to content

Commit

Permalink
Assert unlock doesn't underflow lock user count.
Browse files Browse the repository at this point in the history
While debugging a double unlock error we hit this condition and
debugging would have been a lot easier had we enforced this simple
constraint that we can't decrement the lock users count if it's
already 0.

Signed-off-by: Auke Kok <[email protected]>
  • Loading branch information
aversecat committed Dec 6, 2024
1 parent 689a892 commit c6eec81
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions kmod/src/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ static void lock_inc_count(unsigned int *counts, enum scoutfs_lock_mode mode)
static void lock_dec_count(unsigned int *counts, enum scoutfs_lock_mode mode)
{
BUG_ON(mode < 0 || mode >= SCOUTFS_LOCK_NR_MODES);
BUG_ON(counts[mode] == 0);
counts[mode]--;
}

Expand Down

0 comments on commit c6eec81

Please sign in to comment.