ext4: avoid potential extra brelse in setup_new_flex_group_blocks()
authorVasily Averin <vvs@virtuozzo.com>
Sat, 3 Nov 2018 20:13:17 +0000 (16:13 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 Nov 2018 08:24:11 +0000 (09:24 +0100)
commit4e7e558e8bfa8017a04a9735fc2ed65cf3b1ea3c
treefe3cc28ca3f0b9bf32fcdb8d55d06456eed1ed70
parent64176ffd7ffcd22dd748cf800fd3c1df8d18a137
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>
Cc: stable@kernel.org # 3.3+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/resize.c