diff options
author | Lukas Czerner <lczerner@redhat.com> | 2012-10-15 18:56:49 +0200 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2012-10-15 18:56:49 +0200 |
commit | 76495ec1d47e1c0fe0673faf9179bda6bc8ab5c2 (patch) | |
tree | c5be4c023a0ea0fa109bde78d2315f57b2d4b8a2 /fs | |
parent | ext4: fix metadata checksum calculation for the superblock (diff) | |
download | linux-76495ec1d47e1c0fe0673faf9179bda6bc8ab5c2.tar.xz linux-76495ec1d47e1c0fe0673faf9179bda6bc8ab5c2.zip |
ext4: fix undefined bit shift result in ext4_fill_flex_info
The result of the bit shift expression in
'1 << sbi->s_log_groups_per_flex' can be undefined in the case that
s_log_groups_per_flex is 31 because the result of the shift is bigger
than INT_MAX. In reality this probably should not cause much problems
since we'll end up with INT_MIN which will then be converted into
'unsigned int' type, but nevertheless according to the ISO C99 the
result is actually undefined.
Fix this by changing the left operand to 'unsigned int' type.
Note that the commit d50f2ab6f050311dbf7b8f5501b25f0bf64a439b already
tried to fix the undefined behaviour, but this was missed.
Thanks to Laszlo Ersek for pointing this out and suggesting the fix.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reported-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/super.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 5ededf135335..8ab650b1aa1e 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1970,7 +1970,7 @@ static int ext4_fill_flex_info(struct super_block *sb) sbi->s_log_groups_per_flex = 0; return 1; } - groups_per_flex = 1 << sbi->s_log_groups_per_flex; + groups_per_flex = 1U << sbi->s_log_groups_per_flex; err = ext4_alloc_flex_bg_array(sb, sbi->s_groups_count); if (err) |