add patch avoid-memory-leak-of-s_journal_flag_rwsem-on-error-path
[ext4-patch-queue.git] / add-missing-brelse-on-set_flex_bg_block_bitmap_error_path
blob398a1d6602a30a9a36b93530c20b388a199a73f0
1 ext4: add missing brelse() in set_flexbg_block_bitmap()'s error path
3 From: Vasily Averin <vvs@virtuozzo.com>
5 Fixes: 33afdcc5402d ("ext4: add a function which sets up group blocks ...")
6 Cc: stable@kernel.org # 3.3
7 Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
8 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 ---
10  fs/ext4/resize.c | 6 ++++--
11  1 file changed, 4 insertions(+), 2 deletions(-)
13 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
14 index c3fa30878ca8..0a4dc6217e78 100644
15 --- a/fs/ext4/resize.c
16 +++ b/fs/ext4/resize.c
17 @@ -459,16 +459,18 @@ static int set_flexbg_block_bitmap(struct super_block *sb, handle_t *handle,
19                 BUFFER_TRACE(bh, "get_write_access");
20                 err = ext4_journal_get_write_access(handle, bh);
21 -               if (err)
22 +               if (err) {
23 +                       brelse(bh);
24                         return err;
25 +               }
26                 ext4_debug("mark block bitmap %#04llx (+%llu/%u)\n",
27                            first_cluster, first_cluster - start, count2);
28                 ext4_set_bits(bh->b_data, first_cluster - start, count2);
30                 err = ext4_handle_dirty_metadata(handle, NULL, bh);
31 +               brelse(bh);
32                 if (unlikely(err))
33                         return err;
34 -               brelse(bh);
35         }
37         return 0;
38 -- 
39 2.17.1