[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2aeffa33-e591-acad-f96f-59cfadb5aeb2@suse.com>
Date: Thu, 21 Apr 2022 14:21:41 +0300
From: Nikolay Borisov <nborisov@...e.com>
To: Haowen Bai <baihaowen@...zu.com>, Chris Mason <clm@...com>,
Josef Bacik <josef@...icpanda.com>,
David Sterba <dsterba@...e.com>
Cc: linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] btrfs: Fix a memory leak in btrfs_ioctl_balance()
On 21.04.22 г. 12:51 ч., Haowen Bai wrote:
> Free "bargs" before return.
>
> Signed-off-by: Haowen Bai <baihaowen@...zu.com>
> ---
> fs/btrfs/ioctl.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index f08233c2b0b2..d4c8bea914b7 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -4389,13 +4389,13 @@ static long btrfs_ioctl_balance(struct file *file, void __user *arg)
> /* this is (2) */
> mutex_unlock(&fs_info->balance_mutex);
> ret = -EINPROGRESS;
> - goto out;
> + goto out_bargs;
> }
> } else {
> /* this is (1) */
> mutex_unlock(&fs_info->balance_mutex);
> ret = BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS;
> - goto out;
> + goto out_bargs;
> }
>
> locked:
I think this is a better fix:
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 7a6974e877f4..906ed1b93654 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -4391,15 +4391,13 @@ static long btrfs_ioctl_balance(struct file
*file, void __user *arg)
goto again;
} else {
/* this is (2) */
- mutex_unlock(&fs_info->balance_mutex);
ret = -EINPROGRESS;
- goto out;
+ goto out_bargs;
}
} else {
/* this is (1) */
- mutex_unlock(&fs_info->balance_mutex);
ret = BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS;
- goto out;
+ goto out_bargs;
}
locked:
Powered by blists - more mailing lists