Skip to contentSkip to conversation

Btrfs: fix memory leak in btrfs_pause_balance()

PATCH In review Miao Xie 2 participants 3 messages May 17, 2012 – May 18, 2012 Btrfs file system

lore
Share & tools
lore

Miao Xie

author
#0 lore raw

PATCH 5/5 Btrfs: fix memory leak in btrfs_pause_balance()

We forget to free fs_info->balance_ctl in the btrfs_pause_balance() when umounting the fs.

---
 fs/btrfs/volumes.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
fs/btrfs/volumes.c +3 -0
index c536d52..fd7fe80 100644
@@ -2937,6 +2937,9 @@ int btrfs_pause_balance(struct btrfs_fs_info *fs_info)
 		ret = -ENOTCONN;
 	}
 
+	if (btrfs_fs_closing(fs_info) && fs_info->balance_ctl)
+		unset_balance_control(fs_info);
+
 	mutex_unlock(&fs_info->balance_mutex);
 	return ret;
 }
Signature · 1 line
1.7.6.5
#1 lore raw
Quoted 13 lines · Miao Xie

We forget to free fs_info->balance_ctl in the btrfs_pause_balance() when umounting the fs.

---
 fs/btrfs/volumes.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
fs/btrfs/volumes.c +0 -0
index c536d52..fd7fe80 100644

fs/btrfs/volumes.c int btrfs_pause_balance(struct btrfs_fs_info *fs_info) · line 2945

Quoted 9 lines
fs/btrfs/volumes.c +3 -0
@@ -2937,6 +2937,9 @@ int btrfs_pause_balance(struct btrfs_fs_info *fs_info)
 		ret = -ENOTCONN;
 	}
 
+	if (btrfs_fs_closing(fs_info) && fs_info->balance_ctl)
+		unset_balance_control(fs_info);
+
 	mutex_unlock(&fs_info->balance_mutex);
 	return ret;
 }

It is kfree()'d in free_fs_info(), which should be called on unmount. Am I missing something here ?

Thanks,

Ilya

author
#2 lore raw
Quoted 17 lines · Ilya Dryomov
Quoted 16 lines · Miao Xie

We forget to free fs_info->balance_ctl in the btrfs_pause_balance() when umounting the fs.

---
 fs/btrfs/volumes.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
fs/btrfs/volumes.c +0 -0
index c536d52..fd7fe80 100644
@@ -2937,6 +2937,9 @@ int btrfs_pause_balance(struct btrfs_fs_info *fs_info)
 		ret = -ENOTCONN;
 	}
 
Quoted 9 lines

fs/btrfs/volumes.c int btrfs_pause_balance(struct btrfs_fs_info *fs_info) · line 2945

Quoted 6 lines
fs/btrfs/volumes.c +3 -0
+	if (btrfs_fs_closing(fs_info) && fs_info->balance_ctl)
+		unset_balance_control(fs_info);
+
 	mutex_unlock(&fs_info->balance_mutex);
 	return ret;
 }

It is kfree()'d in free_fs_info(), which should be called on unmount. Am I missing something here ?

It is my mistake. Sorry.

BTW I think freeing it in btrfs_pause_balance() is better because it is relative to the balance, or the readability will become worse.

Thanks
Miao