diff options
author | Christoph Jaeger <christophjaeger@linux.com> | 2014-04-12 07:33:13 -0400 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-04-14 14:31:08 -0400 |
commit | 0040e606e35a0db80fc3fac04ccc7c7176a8e2b1 (patch) | |
tree | 42978de09e95365ba46df73587b3a30149566247 /fs | |
parent | e4fbaee29272533a242f117d18712e2974520d2c (diff) |
btrfs: fix use-after-free in mount_subvol()
Pointer 'newargs' is used after the memory that it points to has already
been freed.
Picked up by Coverity - CID 1201425.
Fixes: 0723a0473f ("btrfs: allow mounting btrfs subvolumes with
different ro/rw options")
Signed-off-by: Christoph Jaeger <christophjaeger@linux.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/super.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 994c40955315..53bc3733d483 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -1186,7 +1186,6 @@ static struct dentry *mount_subvol(const char *subvol_name, int flags, | |||
1186 | return ERR_PTR(-ENOMEM); | 1186 | return ERR_PTR(-ENOMEM); |
1187 | mnt = vfs_kern_mount(&btrfs_fs_type, flags, device_name, | 1187 | mnt = vfs_kern_mount(&btrfs_fs_type, flags, device_name, |
1188 | newargs); | 1188 | newargs); |
1189 | kfree(newargs); | ||
1190 | 1189 | ||
1191 | if (PTR_RET(mnt) == -EBUSY) { | 1190 | if (PTR_RET(mnt) == -EBUSY) { |
1192 | if (flags & MS_RDONLY) { | 1191 | if (flags & MS_RDONLY) { |
@@ -1196,17 +1195,22 @@ static struct dentry *mount_subvol(const char *subvol_name, int flags, | |||
1196 | int r; | 1195 | int r; |
1197 | mnt = vfs_kern_mount(&btrfs_fs_type, flags | MS_RDONLY, device_name, | 1196 | mnt = vfs_kern_mount(&btrfs_fs_type, flags | MS_RDONLY, device_name, |
1198 | newargs); | 1197 | newargs); |
1199 | if (IS_ERR(mnt)) | 1198 | if (IS_ERR(mnt)) { |
1199 | kfree(newargs); | ||
1200 | return ERR_CAST(mnt); | 1200 | return ERR_CAST(mnt); |
1201 | } | ||
1201 | 1202 | ||
1202 | r = btrfs_remount(mnt->mnt_sb, &flags, NULL); | 1203 | r = btrfs_remount(mnt->mnt_sb, &flags, NULL); |
1203 | if (r < 0) { | 1204 | if (r < 0) { |
1204 | /* FIXME: release vfsmount mnt ??*/ | 1205 | /* FIXME: release vfsmount mnt ??*/ |
1206 | kfree(newargs); | ||
1205 | return ERR_PTR(r); | 1207 | return ERR_PTR(r); |
1206 | } | 1208 | } |
1207 | } | 1209 | } |
1208 | } | 1210 | } |
1209 | 1211 | ||
1212 | kfree(newargs); | ||
1213 | |||
1210 | if (IS_ERR(mnt)) | 1214 | if (IS_ERR(mnt)) |
1211 | return ERR_CAST(mnt); | 1215 | return ERR_CAST(mnt); |
1212 | 1216 | ||