1 ext4: avoid potential extra brelse in setup_new_flex_group_blocks()
3 From: Vasily Averin <vvs@virtuozzo.com>
5 Currently bh is set to NULL only during first iteration of for cycle,
6 then this pointer is not cleared after end of using.
7 Therefore rollback after errors can lead to extra brelse(bh) call,
8 decrements bh counter and later trigger an unexpected warning in __brelse()
10 Patch moves brelse() calls in body of cycle to exclude requirement of
11 brelse() call in rollback.
13 Fixes: 33afdcc5402d ("ext4: add a function which sets up group blocks ...")
14 Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
15 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
16 Cc: stable@kernel.org # 3.3+
18 fs/ext4/resize.c | 8 ++------
19 1 file changed, 2 insertions(+), 6 deletions(-)
21 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
22 index ebbc663d0798..c3fa30878ca8 100644
23 --- a/fs/ext4/resize.c
24 +++ b/fs/ext4/resize.c
25 @@ -605,7 +605,6 @@ static int setup_new_flex_group_blocks(struct super_block *sb,
26 bh = bclean(handle, sb, block);
32 overhead = ext4_group_overhead_blocks(sb, group);
33 @@ -618,9 +617,9 @@ static int setup_new_flex_group_blocks(struct super_block *sb,
34 ext4_mark_bitmap_end(EXT4_B2C(sbi, group_data[i].blocks_count),
35 sb->s_blocksize * 8, bh->b_data);
36 err = ext4_handle_dirty_metadata(handle, NULL, bh);
43 if (bg_flags[i] & EXT4_BG_INODE_UNINIT)
44 @@ -635,18 +634,16 @@ static int setup_new_flex_group_blocks(struct super_block *sb,
45 bh = bclean(handle, sb, block);
52 ext4_mark_bitmap_end(EXT4_INODES_PER_GROUP(sb),
53 sb->s_blocksize * 8, bh->b_data);
54 err = ext4_handle_dirty_metadata(handle, NULL, bh);
62 /* Mark group tables in block bitmap */
63 for (j = 0; j < GROUP_TABLE_COUNT; j++) {
64 @@ -685,7 +682,6 @@ static int setup_new_flex_group_blocks(struct super_block *sb,
69 err2 = ext4_journal_stop(handle);