From a4b0a74c7f346cab0a9ae3f8f55bd1a372e14336 Mon Sep 17 00:00:00 2001 From: winglq Date: Tue, 7 Jul 2020 02:46:17 +0800 Subject: [PATCH] Fix atomic_clear_long_excl wrong return When clearing a bit, we should check whether that bit is 0. Note atomic_clear_long_excl is not used. Reviewed-by: Brian Behlendorf Reviewed-by: Ryan Moeller Signed-off-by: Liu Qing Closes #10526 --- lib/libspl/asm-generic/atomic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/libspl/asm-generic/atomic.c b/lib/libspl/asm-generic/atomic.c index f03f93609a..35535ea49c 100644 --- a/lib/libspl/asm-generic/atomic.c +++ b/lib/libspl/asm-generic/atomic.c @@ -415,7 +415,7 @@ atomic_clear_long_excl(volatile ulong_t *target, uint_t value) VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); bit = (1UL << value); - if ((*target & bit) != 0) { + if ((*target & bit) == 0) { VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); return (-1); }