From 0f47e83c98c14c450ff34e964ece3d61b1b1b3bb Mon Sep 17 00:00:00 2001 From: Liu Qing Date: Thu, 2 Jul 2020 17:07:26 +0800 Subject: [PATCH 1/2] fix atomic_clear_long_excl wrong return When clear a bit, we should check whether that bit is 1. BTW atomic_clear_long_excl is not used. Signed-off-by: Liu Qing --- 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 f03f93609a25..82f70dbadb9c 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) != 1) { VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); return (-1); } From b88a0a01f2c1aa2ecd073c43a868d861b4189d76 Mon Sep 17 00:00:00 2001 From: winglq Date: Fri, 3 Jul 2020 09:18:35 +0800 Subject: [PATCH 2/2] Update lib/libspl/asm-generic/atomic.c Co-authored-by: Ryan Moeller --- 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 82f70dbadb9c..35535ea49c79 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) != 1) { + if ((*target & bit) == 0) { VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); return (-1); }