* [PATCH] btrfs: fix a memory leak issue in read_one_chunk()
@ 2025-03-03 2:42 Haoxiang Li
2025-03-03 4:24 ` Qu Wenruo
2025-03-05 11:53 ` Filipe Manana
0 siblings, 2 replies; 3+ messages in thread
From: Haoxiang Li @ 2025-03-03 2:42 UTC (permalink / raw)
To: clm, josef, dsterba, fdmanana
Cc: linux-btrfs, linux-kernel, Haoxiang Li, stable
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
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
---
fs/btrfs/volumes.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index fb22d4425cb0..3f8afbd1ebb5 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -7155,6 +7155,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;
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] btrfs: fix a memory leak issue in read_one_chunk()
2025-03-03 2:42 [PATCH] btrfs: fix a memory leak issue in read_one_chunk() Haoxiang Li
@ 2025-03-03 4:24 ` Qu Wenruo
2025-03-05 11:53 ` Filipe Manana
1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2025-03-03 4:24 UTC (permalink / raw)
To: Haoxiang Li, clm, josef, dsterba, fdmanana
Cc: linux-btrfs, linux-kernel, stable
在 2025/3/3 13:12, Haoxiang Li 写道:
> 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
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
And the fixes tag is also correct, before that commit, add_extent_map()
will increase the ref if tree_insert() succeeded, thus if it failed the
unconditional free_extent_map() will just free the no longer utilized em.
But at that commit, we no longer has that feature, thus has to manually
cleanup the map.
Thanks,
Qu
> ---
> fs/btrfs/volumes.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index fb22d4425cb0..3f8afbd1ebb5 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -7155,6 +7155,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;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] btrfs: fix a memory leak issue in read_one_chunk()
2025-03-03 2:42 [PATCH] btrfs: fix a memory leak issue in read_one_chunk() Haoxiang Li
2025-03-03 4:24 ` Qu Wenruo
@ 2025-03-05 11:53 ` Filipe Manana
1 sibling, 0 replies; 3+ messages in thread
From: Filipe Manana @ 2025-03-05 11:53 UTC (permalink / raw)
To: Haoxiang Li
Cc: clm, josef, dsterba, fdmanana, linux-btrfs, linux-kernel, stable
On Mon, Mar 3, 2025 at 2:43 AM Haoxiang Li <haoxiang_li2024@163.com> wrote:
>
> 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
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Pushed into the github for-next branch, thanks.
> ---
> fs/btrfs/volumes.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index fb22d4425cb0..3f8afbd1ebb5 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -7155,6 +7155,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;
> --
> 2.25.1
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-05 11:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-03 2:42 [PATCH] btrfs: fix a memory leak issue in read_one_chunk() Haoxiang Li
2025-03-03 4:24 ` Qu Wenruo
2025-03-05 11:53 ` Filipe Manana
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®