]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ext4: add missed brelse in ext4_free_blocks_simple
authorKemeng Shi <shikemeng@huaweicloud.com>
Fri, 3 Mar 2023 17:21:07 +0000 (01:21 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 6 Apr 2023 05:13:11 +0000 (01:13 -0400)
Release bitmap buffer_head we got if error occurs.
Besides, this patch remove unused assignment to err.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Link: https://lore.kernel.org/r/20230303172120.3800725-8-shikemeng@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/mballoc.c

index 9d4091fad78d7f3d8475b8874b423756e270e626..87ff3bfbafd8f71838c721a0ca725a1ad7e8fa41 100644 (file)
@@ -5849,13 +5849,12 @@ static void ext4_free_blocks_simple(struct inode *inode, ext4_fsblk_t block,
        ext4_get_group_no_and_offset(sb, block, &group, &blkoff);
        bitmap_bh = ext4_read_block_bitmap(sb, group);
        if (IS_ERR(bitmap_bh)) {
-               err = PTR_ERR(bitmap_bh);
                pr_warn("Failed to read block bitmap\n");
                return;
        }
        gdp = ext4_get_group_desc(sb, group, &gdp_bh);
        if (!gdp)
-               return;
+               goto err_out;
 
        for (i = 0; i < count; i++) {
                if (!mb_test_bit(blkoff + i, bitmap_bh->b_data))
@@ -5864,7 +5863,7 @@ static void ext4_free_blocks_simple(struct inode *inode, ext4_fsblk_t block,
        mb_clear_bits(bitmap_bh->b_data, blkoff, count);
        err = ext4_handle_dirty_metadata(NULL, NULL, bitmap_bh);
        if (err)
-               return;
+               goto err_out;
        ext4_free_group_clusters_set(
                sb, gdp, ext4_free_group_clusters(sb, gdp) +
                count - already_freed);
@@ -5873,6 +5872,8 @@ static void ext4_free_blocks_simple(struct inode *inode, ext4_fsblk_t block,
        ext4_handle_dirty_metadata(NULL, NULL, gdp_bh);
        sync_dirty_buffer(bitmap_bh);
        sync_dirty_buffer(gdp_bh);
+
+err_out:
        brelse(bitmap_bh);
 }