diff options
author | Nickolai Zeldovich <nickolai@csail.mit.edu> | 2013-01-05 20:19:21 +0100 |
---|---|---|
committer | Dave Kleikamp <dave.kleikamp@oracle.com> | 2013-01-07 15:21:36 +0100 |
commit | 9d48017bce890b19e3bba649850bdbc8a6f95903 (patch) | |
tree | ece6878230600e39daafc2169afaced628cac871 /fs/jfs/jfs_imap.c | |
parent | Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/cmar... (diff) | |
download | linux-9d48017bce890b19e3bba649850bdbc8a6f95903.tar.xz linux-9d48017bce890b19e3bba649850bdbc8a6f95903.zip |
jfs: avoid undefined behavior from left-shifting by 32 bits
Shifting a 32-bit int by 32 bits is undefined behavior in C, and
results in different behavior on different architectures (e.g., x86
and PowerPC). diAlloc() in fs/jfs/jfs_imap.c computes a mask using
0xffffffffu<<(32-bitno), which can left-shift by 32 bits. To avoid
unexpected behavior, explicitly check for bitno==0 and use a 0 mask.
Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu>
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Diffstat (limited to 'fs/jfs/jfs_imap.c')
-rw-r--r-- | fs/jfs/jfs_imap.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c index 6ba4006e011b..f7e042b63ddb 100644 --- a/fs/jfs/jfs_imap.c +++ b/fs/jfs/jfs_imap.c @@ -1493,7 +1493,7 @@ int diAlloc(struct inode *pip, bool dir, struct inode *ip) /* mask any prior bits for the starting words of the * summary map. */ - mask = ONES << (EXTSPERSUM - bitno); + mask = (bitno == 0) ? 0 : (ONES << (EXTSPERSUM - bitno)); inosmap = le32_to_cpu(iagp->inosmap[sword]) | mask; extsmap = le32_to_cpu(iagp->extsmap[sword]) | mask; |