Skip to contentSkip to conversation

btrfs - fix memory leak on finding existing super

PATCH In review Ian Kent 3 participants 3 messages Nov 30, 2010 – Dec 1, 2010 Btrfs file system

lore
Share & tools
lore

Ian Kent

author
#0 lore raw

PATCH 1/1 btrfs - fix memory leak on finding existing super

From: Ian Kent <[email protected]>

We missed a memory deallocation in commit 450ba0ea.

If an existing super block is found at mount and there is no error condition then the pre-allocated tree_root and fs_info are no not used and are not freeded.

---

 fs/btrfs/super.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/btrfs/super.c +2 -0
index 47bf67c..f5cca1b 100644
@@ -654,6 +654,8 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags,
 		}
 
 		btrfs_close_devices(fs_devices);
+		kfree(fs_info);
+		kfree(tree_root);
 	} else {
 		char b[BDEVNAME_SIZE];
 
#1 lore raw
Quoted 7 lines · Ian Kent

From: Ian Kent <[email protected]>

We missed a memory deallocation in commit 450ba0ea.

If an existing super block is found at mount and there is no error condition then the pre-allocated tree_root and fs_info are no not used and are not freeded.

It's hard to believe that spelling looked OK to me before posting, ;)

Quoted 25 lines

---

 fs/btrfs/super.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/btrfs/super.c +2 -1
index 47bf67c..f5cca1b 100644
@@ -654,6 +654,8 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags,
 		}
 
 		btrfs_close_devices(fs_devices);
+		kfree(fs_info);
+		kfree(tree_root);
 	} else {
 		char b[BDEVNAME_SIZE];
 
 
--

To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Reviewed-by on v1 1/1
#2 lore raw
In reply to Ian Kent
Quoted 9 lines · Ian Kent

From: Ian Kent <[email protected]>

We missed a memory deallocation in commit 450ba0ea.

If an existing super block is found at mount and there is no error condition then the pre-allocated tree_root and fs_info are no not used and are not freeded.

Quoted 18 lines

---

 fs/btrfs/super.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/btrfs/super.c +2 -0
index 47bf67c..f5cca1b 100644
@@ -654,6 +654,8 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags,
 		}
 
 		btrfs_close_devices(fs_devices);
+		kfree(fs_info);
+		kfree(tree_root);
 	} else {
 		char b[BDEVNAME_SIZE];