add patch remove-debug-dependency-on-debug_fs-update-help-text
[ext4-patch-queue.git] / add-sanity-check-to-ext4_get_group_info
blob5ecdb029870f3ff8428bdf6414fe5d8d070fc88b
1 ext4: add sanity check to ext4_get_group_info()
3 The group number passed to ext4_get_group_info() should be valid, but
4 let's add an assert to check this before we start creating a pointer
5 based on that group number and dereferencing it.
7 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
8 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
9 index bd9890f..f85f1fb 100644
10 --- a/fs/ext4/ext4.h
11 +++ b/fs/ext4/ext4.h
12 @@ -2313,6 +2313,7 @@ struct ext4_group_info *ext4_get_group_info(struct super_block *sb,
13  {
14          struct ext4_group_info ***grp_info;
15          long indexv, indexh;
16 +        BUG_ON(group >= EXT4_SB(sb)->s_groups_count);
17          grp_info = EXT4_SB(sb)->s_group_info;
18          indexv = group >> (EXT4_DESC_PER_BLOCK_BITS(sb));
19          indexh = group & ((EXT4_DESC_PER_BLOCK(sb)) - 1);