diff options
| author | Miklos Szeredi <mszeredi@redhat.com> | 2018-10-15 09:43:06 -0400 |
|---|---|---|
| committer | Miklos Szeredi <mszeredi@redhat.com> | 2018-10-15 09:43:06 -0400 |
| commit | edfa87281f4fa1b78a21f6db999935a2faa2f6b8 (patch) | |
| tree | a8cf448df087ed559e97a09f1adf0bb5f7c59f12 | |
| parent | 18127429a854e7607b859484880b8e26cee9ddab (diff) | |
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: 85ad1d13ee9b ("md: set MD_CHANGE_PENDING in a atomic region")
Cc: Guoqing Jiang <gqjiang@suse.com>
| -rw-r--r-- | include/linux/bitops.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index d18ee0e63c32..705f7c442691 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h | |||
| @@ -251,18 +251,18 @@ static __always_inline void __assign_bit(long nr, volatile unsigned long *addr, | |||
| 251 | #endif | 251 | #endif |
| 252 | 252 | ||
| 253 | #ifndef bit_clear_unless | 253 | #ifndef bit_clear_unless |
| 254 | #define bit_clear_unless(ptr, _clear, _test) \ | 254 | #define bit_clear_unless(ptr, clear, test) \ |
| 255 | ({ \ | 255 | ({ \ |
| 256 | const typeof(*ptr) clear = (_clear), test = (_test); \ | 256 | const typeof(*(ptr)) clear__ = (clear), test__ = (test);\ |
| 257 | typeof(*ptr) old, new; \ | 257 | typeof(*(ptr)) old__, new__; \ |
| 258 | \ | 258 | \ |
| 259 | do { \ | 259 | do { \ |
| 260 | old = READ_ONCE(*ptr); \ | 260 | old__ = READ_ONCE(*(ptr)); \ |
| 261 | new = old & ~clear; \ | 261 | new__ = old__ & ~clear__; \ |
| 262 | } while (!(old & test) && \ | 262 | } while (!(old__ & test__) && \ |
| 263 | cmpxchg(ptr, old, new) != old); \ | 263 | cmpxchg(ptr, old__, new__) != old__); \ |
| 264 | \ | 264 | \ |
| 265 | !(old & test); \ | 265 | !(old__ & test__); \ |
| 266 | }) | 266 | }) |
| 267 | #endif | 267 | #endif |
| 268 | 268 | ||
