1
0
Fork 0

bitops: protect variables in bit_clear_unless() macro

Unprotected naming of local variables within bit_clear_unless() can easily
lead to using the wrong scope.

Noticed this by code review after having hit this issue in set_mask_bits()

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Fixes: 85ad1d13ee ("md: set MD_CHANGE_PENDING in a atomic region")
Cc: Guoqing Jiang <gqjiang@suse.com>
hifive-unleashed-5.1
Miklos Szeredi 2018-10-15 15:43:06 +02:00
parent 18127429a8
commit edfa87281f
1 changed files with 8 additions and 8 deletions

View File

@ -251,18 +251,18 @@ static __always_inline void __assign_bit(long nr, volatile unsigned long *addr,
#endif #endif
#ifndef bit_clear_unless #ifndef bit_clear_unless
#define bit_clear_unless(ptr, _clear, _test) \ #define bit_clear_unless(ptr, clear, test) \
({ \ ({ \
const typeof(*ptr) clear = (_clear), test = (_test); \ const typeof(*(ptr)) clear__ = (clear), test__ = (test);\
typeof(*ptr) old, new; \ typeof(*(ptr)) old__, new__; \
\ \
do { \ do { \
old = READ_ONCE(*ptr); \ old__ = READ_ONCE(*(ptr)); \
new = old & ~clear; \ new__ = old__ & ~clear__; \
} while (!(old & test) && \ } while (!(old__ & test__) && \
cmpxchg(ptr, old, new) != old); \ cmpxchg(ptr, old__, new__) != old__); \
\ \
!(old & test); \ !(old__ & test__); \
}) })
#endif #endif