diff options
author | Vasily Averin <vvs@virtuozzo.com> | 2018-11-03 16:13:17 -0400 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2019-02-11 17:53:46 +0000 |
commit | 496becbc3b9b4204b5ca18f7ddf707413a420283 (patch) | |
tree | 2bc27570ebcf0c6b7204fe8d241810791f182325 /fs | |
parent | 5969b6788260ad4f0e26d514b7423574d8f80b29 (diff) | |
download | linux-stable-496becbc3b9b4204b5ca18f7ddf707413a420283.tar.gz linux-stable-496becbc3b9b4204b5ca18f7ddf707413a420283.tar.bz2 linux-stable-496becbc3b9b4204b5ca18f7ddf707413a420283.zip |
ext4: avoid potential extra brelse in setup_new_flex_group_blocks()
commit 9e4028935cca3f9ef9b6a90df9da6f1f94853536 upstream.
Currently bh is set to NULL only during first iteration of for cycle,
then this pointer is not cleared after end of using.
Therefore rollback after errors can lead to extra brelse(bh) call,
decrements bh counter and later trigger an unexpected warning in __brelse()
Patch moves brelse() calls in body of cycle to exclude requirement of
brelse() call in rollback.
Fixes: 33afdcc5402d ("ext4: add a function which sets up group blocks ...")
Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/resize.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index 52fb5c7db73d..985252a0afb2 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c @@ -588,7 +588,6 @@ handle_bb: bh = bclean(handle, sb, block); if (IS_ERR(bh)) { err = PTR_ERR(bh); - bh = NULL; goto out; } overhead = ext4_group_overhead_blocks(sb, group); @@ -600,9 +599,9 @@ handle_bb: ext4_mark_bitmap_end(group_data[i].blocks_count, sb->s_blocksize * 8, bh->b_data); err = ext4_handle_dirty_metadata(handle, NULL, bh); + brelse(bh); if (err) goto out; - brelse(bh); handle_ib: if (bg_flags[i] & EXT4_BG_INODE_UNINIT) @@ -617,18 +616,16 @@ handle_ib: bh = bclean(handle, sb, block); if (IS_ERR(bh)) { err = PTR_ERR(bh); - bh = NULL; goto out; } ext4_mark_bitmap_end(EXT4_INODES_PER_GROUP(sb), sb->s_blocksize * 8, bh->b_data); err = ext4_handle_dirty_metadata(handle, NULL, bh); + brelse(bh); if (err) goto out; - brelse(bh); } - bh = NULL; /* Mark group tables in block bitmap */ for (j = 0; j < GROUP_TABLE_COUNT; j++) { @@ -659,7 +656,6 @@ handle_ib: } out: - brelse(bh); err2 = ext4_journal_stop(handle); if (err2 && !err) err = err2; |