linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs/btrfs: On error always free subvol_name in btrfs_mount
@ 2019-01-30 13:54 Eric W. Biederman
  2019-01-30 14:50 ` Nikolay Borisov
  2019-01-30 17:09 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Eric W. Biederman @ 2019-01-30 13:54 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba; +Cc: linux-btrfs, linux-fsdevel


The subvol_name is allocated in btrfs_parse_subvol_options and is
consumed and freed in mount_subvol.  Add a free to the error paths that
don't call mount_subvol so that it is guaranteed that subvol_name is
freed when an error happens.

Fixes: 312c89fbca06 ("btrfs: cleanup btrfs_mount() using btrfs_mount_root()")
Cc: stable@vger.kernel.org
Cc: Chris Mason <clm@fb.com>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
 fs/btrfs/super.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index c5586ffd1426..0a3f122dd61f 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1621,6 +1621,7 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags,
 				flags | SB_RDONLY, device_name, data);
 			if (IS_ERR(mnt_root)) {
 				root = ERR_CAST(mnt_root);
+				kfree(subvol_name);
 				goto out;
 			}
 
@@ -1630,12 +1631,14 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags,
 			if (error < 0) {
 				root = ERR_PTR(error);
 				mntput(mnt_root);
+				kfree(subvol_name);
 				goto out;
 			}
 		}
 	}
 	if (IS_ERR(mnt_root)) {
 		root = ERR_CAST(mnt_root);
+		kfree(subvol_name);
 		goto out;
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] fs/btrfs: On error always free subvol_name in btrfs_mount
  2019-01-30 13:54 [PATCH] fs/btrfs: On error always free subvol_name in btrfs_mount Eric W. Biederman
@ 2019-01-30 14:50 ` Nikolay Borisov
  2019-01-30 17:09 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Nikolay Borisov @ 2019-01-30 14:50 UTC (permalink / raw)
  To: Eric W. Biederman, Chris Mason, Josef Bacik, David Sterba
  Cc: linux-btrfs, linux-fsdevel



On 30.01.19 г. 15:54 ч., Eric W. Biederman wrote:
> 
> The subvol_name is allocated in btrfs_parse_subvol_options and is
> consumed and freed in mount_subvol.  Add a free to the error paths that
> don't call mount_subvol so that it is guaranteed that subvol_name is
> freed when an error happens.


Good catch,

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> 
> Fixes: 312c89fbca06 ("btrfs: cleanup btrfs_mount() using btrfs_mount_root()")
> Cc: stable@vger.kernel.org
> Cc: Chris Mason <clm@fb.com>
> Cc: Josef Bacik <josef@toxicpanda.com>
> Cc: David Sterba <dsterba@suse.com>
> Cc: linux-btrfs@vger.kernel.org
> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
> ---
>  fs/btrfs/super.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index c5586ffd1426..0a3f122dd61f 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -1621,6 +1621,7 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags,
>  				flags | SB_RDONLY, device_name, data);
>  			if (IS_ERR(mnt_root)) {
>  				root = ERR_CAST(mnt_root);
> +				kfree(subvol_name);
>  				goto out;
>  			}
>  
> @@ -1630,12 +1631,14 @@ static struct dentry *btrfs_mount(struct file_system_type *fs_type, int flags,
>  			if (error < 0) {
>  				root = ERR_PTR(error);
>  				mntput(mnt_root);
> +				kfree(subvol_name);
>  				goto out;
>  			}
>  		}
>  	}
>  	if (IS_ERR(mnt_root)) {
>  		root = ERR_CAST(mnt_root);
> +		kfree(subvol_name);
>  		goto out;
>  	}
>  
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fs/btrfs: On error always free subvol_name in btrfs_mount
  2019-01-30 13:54 [PATCH] fs/btrfs: On error always free subvol_name in btrfs_mount Eric W. Biederman
  2019-01-30 14:50 ` Nikolay Borisov
@ 2019-01-30 17:09 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2019-01-30 17:09 UTC (permalink / raw)
  To: Eric W. Biederman
  Cc: Chris Mason, Josef Bacik, David Sterba, linux-btrfs, linux-fsdevel

On Wed, Jan 30, 2019 at 07:54:12AM -0600, Eric W. Biederman wrote:
> 
> The subvol_name is allocated in btrfs_parse_subvol_options and is
> consumed and freed in mount_subvol.  Add a free to the error paths that
> don't call mount_subvol so that it is guaranteed that subvol_name is
> freed when an error happens.
> 
> Fixes: 312c89fbca06 ("btrfs: cleanup btrfs_mount() using btrfs_mount_root()")
> Cc: stable@vger.kernel.org
> Cc: Chris Mason <clm@fb.com>
> Cc: Josef Bacik <josef@toxicpanda.com>
> Cc: David Sterba <dsterba@suse.com>
> Cc: linux-btrfs@vger.kernel.org
> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

Reviewed-by: David Sterba <dsterba@suse.com>

Added to 5.0-rc queue, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-30 17:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-30 13:54 [PATCH] fs/btrfs: On error always free subvol_name in btrfs_mount Eric W. Biederman
2019-01-30 14:50 ` Nikolay Borisov
2019-01-30 17:09 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).