Btrfs: fix memory leak in btrfs_pause_balance()
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
@@ -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
Quoted 13 lines · Miao Xie
We forget to free
fs_info->balance_ctlin thebtrfs_pause_balance()when umounting the fs.Signed-off-by Miao Xie <[email protected]>--- fs/btrfs/volumes.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)fs/btrfs/volumes.c +0
-0
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
Quoted 17 lines · Ilya Dryomov
Quoted 16 lines · Miao Xie
We forget to free
fs_info->balance_ctlin thebtrfs_pause_balance()when umounting the fs.Signed-off-by Miao Xie <[email protected]>--- fs/btrfs/volumes.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)fs/btrfs/volumes.c +0
-0@@ -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