Skip to contentSkip to conversation

btrfs: fix chunk map leak in btrfs_map_block() after btrfs_translate_remap()

PATCH In review Mark Harmstone 3 participants 4 messages Feb 20 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: fix chunk map leak in btrfs_map_block() after btrfs_translate_remap()

If the call to btrfs_translate_remap() in btrfs_map_block() returns an error code, we were leaking the chunk map. Fix it by jumping to out rather than returning directly.

Fixes 18ba64992871 ("btrfs: redirect I/O for remapped block groups")
---
 fs/btrfs/volumes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/volumes.c +1 -1
index 83e2834ea273..1bd3464ccdd8 100644
@@ -7082,7 +7082,7 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
 
 		ret = btrfs_translate_remap(fs_info, &new_logical, length);
 		if (ret)
-			return ret;
+			goto out;
 
 		if (new_logical != logical) {
 			btrfs_free_chunk_map(map);
Signature · 1 line
2.52.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Mark Harmstone

If the call to btrfs_translate_remap() in btrfs_map_block() returns an error code, we were leaking the chunk map. Fix it by jumping to out rather than returning directly.

Fixes 18ba64992871 ("btrfs: redirect I/O for remapped block groups")

It's a bug fix so this is more a Reported-by rather than a Suggested-by.

Otherwise,

Thanks.

Quoted 21 lines
---
 fs/btrfs/volumes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/volumes.c +1 -2
index 83e2834ea273..1bd3464ccdd8 100644
@@ -7082,7 +7082,7 @@ int btrfs_map_block(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
 
                ret = btrfs_translate_remap(fs_info, &new_logical, length);
                if (ret)
-                       return ret;
+                       goto out;
 
                if (new_logical != logical) {
                        btrfs_free_chunk_map(map);
--

2.52.0

#2 lore raw
In reply to Mark Harmstone
Quoted 7 lines · Mark Harmstone

If the call to btrfs_translate_remap() in btrfs_map_block() returns an error code, we were leaking the chunk map. Fix it by jumping to out rather than returning directly.

Fixes 18ba64992871 ("btrfs: redirect I/O for remapped block groups")

If it's a but then it's Reported-by

Quoted 1 line

Please sort the tags according to
https://btrfs.readthedocs.io/en/latest/dev/Developer-s-FAQ.html#ordering

as it's been for a long time and saves me editing each patch. Thanks.

#3 lore raw
Quoted 9 lines · David Sterba
Quoted 7 lines · Mark Harmstone

If the call to btrfs_translate_remap() in btrfs_map_block() returns an error code, we were leaking the chunk map. Fix it by jumping to out rather than returning directly.

Fixes 18ba64992871 ("btrfs: redirect I/O for remapped block groups")
Quoted 8 lines

If it's a but then it's Reported-by

Quoted 1 line

Please sort the tags according to
https://btrfs.readthedocs.io/en/latest/dev/Developer-s-FAQ.html#ordering

as it's been for a long time and saves me editing each patch. Thanks.

Okay, I've edited the patches and pushed them with the tags in the right order.