lkml.org 
[lkml]   [2020]   [Apr]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.19 25/54] bitops: protect variables in set_mask_bits() macro
    Date
    From: Miklos Szeredi <mszeredi@redhat.com>

    commit 18127429a854e7607b859484880b8e26cee9ddab upstream.

    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>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    include/linux/bitops.h | 14 +++++++-------
    1 file changed, 7 insertions(+), 7 deletions(-)

    --- a/include/linux/bitops.h
    +++ b/include/linux/bitops.h
    @@ -236,17 +236,17 @@ static __always_inline void __assign_bit
    #ifdef __KERNEL__

    #ifndef set_mask_bits
    -#define set_mask_bits(ptr, _mask, _bits) \
    +#define set_mask_bits(ptr, mask, bits) \
    ({ \
    - const typeof(*ptr) mask = (_mask), bits = (_bits); \
    - typeof(*ptr) old, new; \
    + const typeof(*(ptr)) mask__ = (mask), bits__ = (bits); \
    + typeof(*(ptr)) old__, new__; \
    \
    do { \
    - old = READ_ONCE(*ptr); \
    - new = (old & ~mask) | bits; \
    - } while (cmpxchg(ptr, old, new) != old); \
    + old__ = READ_ONCE(*(ptr)); \
    + new__ = (old__ & ~mask__) | bits__; \
    + } while (cmpxchg(ptr, old__, new__) != old__); \
    \
    - new; \
    + new__; \
    })
    #endif


    \
     
     \ /
      Last update: 2020-04-11 14:17    [W:4.891 / U:0.112 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site