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 <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Signed-off-by: Liu Qing <winglq@gmail.com>
Closes #10526
This commit is contained in:
winglq 2020-07-07 02:46:17 +08:00 committed by GitHub
parent 8a3d9186ba
commit a4b0a74c7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
}