diff options
author | Tao Ma <boyu.mt@taobao.com> | 2011-07-11 18:42:42 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-07-11 18:42:42 -0400 |
commit | caaf7a29d31da21bb8d8200d5e42d1c93d3c6e00 (patch) | |
tree | 880f1cd67f0a8c1fb1dfbb1359358d930b0f611a /fs/ext4/mballoc.c | |
parent | 823ba01fc07751200c43e45733925a98b73eac3a (diff) |
ext4: Fix a double free of sbi->s_group_info in ext4_mb_init_backend
If we meet with an error in ext4_mb_add_groupinfo, we kfree
sbi->s_group_info[group >> EXT4_DESC_PER_BLOCK_BITS(sb)], but fail to
reset it to NULL. So the caller ext4_mb_init_backend will try to kfree
it again and causes a double free. So fix it by resetting it to NULL.
Some typo in comments of mballoc.c are also changed.
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r-- | fs/ext4/mballoc.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 2b9a71b99b2b..b97a2d2f0fdf 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -75,8 +75,8 @@ | |||
75 | * | 75 | * |
76 | * The inode preallocation space is used looking at the _logical_ start | 76 | * The inode preallocation space is used looking at the _logical_ start |
77 | * block. If only the logical file block falls within the range of prealloc | 77 | * block. If only the logical file block falls within the range of prealloc |
78 | * space we will consume the particular prealloc space. This make sure that | 78 | * space we will consume the particular prealloc space. This makes sure that |
79 | * that the we have contiguous physical blocks representing the file blocks | 79 | * we have contiguous physical blocks representing the file blocks |
80 | * | 80 | * |
81 | * The important thing to be noted in case of inode prealloc space is that | 81 | * The important thing to be noted in case of inode prealloc space is that |
82 | * we don't modify the values associated to inode prealloc space except | 82 | * we don't modify the values associated to inode prealloc space except |
@@ -84,7 +84,7 @@ | |||
84 | * | 84 | * |
85 | * If we are not able to find blocks in the inode prealloc space and if we | 85 | * If we are not able to find blocks in the inode prealloc space and if we |
86 | * have the group allocation flag set then we look at the locality group | 86 | * have the group allocation flag set then we look at the locality group |
87 | * prealloc space. These are per CPU prealloc list repreasented as | 87 | * prealloc space. These are per CPU prealloc list represented as |
88 | * | 88 | * |
89 | * ext4_sb_info.s_locality_groups[smp_processor_id()] | 89 | * ext4_sb_info.s_locality_groups[smp_processor_id()] |
90 | * | 90 | * |
@@ -152,7 +152,7 @@ | |||
152 | * best extent in the found extents. Searching for the blocks starts with | 152 | * best extent in the found extents. Searching for the blocks starts with |
153 | * the group specified as the goal value in allocation context via | 153 | * the group specified as the goal value in allocation context via |
154 | * ac_g_ex. Each group is first checked based on the criteria whether it | 154 | * ac_g_ex. Each group is first checked based on the criteria whether it |
155 | * can used for allocation. ext4_mb_good_group explains how the groups are | 155 | * can be used for allocation. ext4_mb_good_group explains how the groups are |
156 | * checked. | 156 | * checked. |
157 | * | 157 | * |
158 | * Both the prealloc space are getting populated as above. So for the first | 158 | * Both the prealloc space are getting populated as above. So for the first |
@@ -2279,8 +2279,10 @@ int ext4_mb_add_groupinfo(struct super_block *sb, ext4_group_t group, | |||
2279 | 2279 | ||
2280 | exit_group_info: | 2280 | exit_group_info: |
2281 | /* If a meta_group_info table has been allocated, release it now */ | 2281 | /* If a meta_group_info table has been allocated, release it now */ |
2282 | if (group % EXT4_DESC_PER_BLOCK(sb) == 0) | 2282 | if (group % EXT4_DESC_PER_BLOCK(sb) == 0) { |
2283 | kfree(sbi->s_group_info[group >> EXT4_DESC_PER_BLOCK_BITS(sb)]); | 2283 | kfree(sbi->s_group_info[group >> EXT4_DESC_PER_BLOCK_BITS(sb)]); |
2284 | sbi->s_group_info[group >> EXT4_DESC_PER_BLOCK_BITS(sb)] = NULL; | ||
2285 | } | ||
2284 | exit_meta_group_info: | 2286 | exit_meta_group_info: |
2285 | return -ENOMEM; | 2287 | return -ENOMEM; |
2286 | } /* ext4_mb_add_groupinfo */ | 2288 | } /* ext4_mb_add_groupinfo */ |