]> www.infradead.org Git - users/hch/misc.git/commitdiff
btrfs: fix a leaked chunk map issue in read_one_chunk()
authorHaoxiang Li <haoxiang_li2024@163.com>
Mon, 3 Mar 2025 02:42:33 +0000 (10:42 +0800)
committerDavid Sterba <dsterba@suse.com>
Thu, 6 Mar 2025 13:40:09 +0000 (14:40 +0100)
Add btrfs_free_chunk_map() to free the memory allocated
by btrfs_alloc_chunk_map() if btrfs_add_chunk_map() fails.

Fixes: 7dc66abb5a47 ("btrfs: use a dedicated data structure for chunk maps")
CC: stable@vger.kernel.org
Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c

index f6ae76815e4b568e172048f0cd2ddc93abd8a2c2..6f8dcf59b5257382ab5eb9befcad597f8c1f3081 100644 (file)
@@ -7151,6 +7151,7 @@ static int read_one_chunk(struct btrfs_key *key, struct extent_buffer *leaf,
                btrfs_err(fs_info,
                          "failed to add chunk map, start=%llu len=%llu: %d",
                          map->start, map->chunk_len, ret);
+               btrfs_free_chunk_map(map);
        }
 
        return ret;