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 | 18127429a854e7607b859484880b8e26cee9ddab (patch) | |
| tree | 3d54b865f04f8a707cbca858c75c80065ac4a6ec | |
| parent | e52a8250480acd3b26534793c61816e30d85fbb6 (diff) | |
bitops: protect variables in set_mask_bits() macro
Unprotected naming of local variables within the set_mask_bits() can easily
lead to using the wrong scope.
Noticed this when "set_mask_bits(&foo->bar, 0, mask)" behaved as no-op.
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Fixes: 00a1a053ebe5 ("ext4: atomically set inode->i_flags in ext4_set_inode_flags()")
Cc: Theodore Ts'o <tytso@mit.edu>
| -rw-r--r-- | include/linux/bitops.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 7ddb1349394d..d18ee0e63c32 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h | |||
| @@ -236,17 +236,17 @@ static __always_inline void __assign_bit(long nr, volatile unsigned long *addr, | |||
| 236 | #ifdef __KERNEL__ | 236 | #ifdef __KERNEL__ |
| 237 | 237 | ||
| 238 | #ifndef set_mask_bits | 238 | #ifndef set_mask_bits |
| 239 | #define set_mask_bits(ptr, _mask, _bits) \ | 239 | #define set_mask_bits(ptr, mask, bits) \ |
| 240 | ({ \ | 240 | ({ \ |
| 241 | const typeof(*ptr) mask = (_mask), bits = (_bits); \ | 241 | const typeof(*(ptr)) mask__ = (mask), bits__ = (bits); \ |
| 242 | typeof(*ptr) old, new; \ | 242 | typeof(*(ptr)) old__, new__; \ |
| 243 | \ | 243 | \ |
| 244 | do { \ | 244 | do { \ |
| 245 | old = READ_ONCE(*ptr); \ | 245 | old__ = READ_ONCE(*(ptr)); \ |
| 246 | new = (old & ~mask) | bits; \ | 246 | new__ = (old__ & ~mask__) | bits__; \ |
| 247 | } while (cmpxchg(ptr, old, new) != old); \ | 247 | } while (cmpxchg(ptr, old__, new__) != old__); \ |
| 248 | \ | 248 | \ |
| 249 | new; \ | 249 | new__; \ |
| 250 | }) | 250 | }) |
| 251 | #endif | 251 | #endif |
| 252 | 252 | ||
