do_add_mount() consumes vfsmount on success; just follow it with
conditional retain_and_null_ptr() on success and we can switch
to __free() for mnt and be done with that - unlock_mount() is
in the very end.
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
{
struct pinned_mountpoint mp = {};
struct super_block *sb;
- struct vfsmount *mnt = fc_mount(fc);
+ struct vfsmount *mnt __free(mntput) = fc_mount(fc);
int error;
if (IS_ERR(mnt))
sb = fc->root->d_sb;
error = security_sb_kern_mount(sb);
- if (!error && mount_too_revealing(sb, &mnt_flags))
- error = -EPERM;
if (unlikely(error))
- goto out;
+ return error;
+
+ if (unlikely(mount_too_revealing(sb, &mnt_flags)))
+ return -EPERM;
mnt_warn_timestamp_expiry(mountpoint, mnt);
error = do_add_mount(real_mount(mnt), mp.mp,
mountpoint, mnt_flags);
if (!error)
- mnt = NULL; // consumed on success
+ retain_and_null_ptr(mnt); // consumed on success
unlock_mount(&mp);
}
-out:
- mntput(mnt);
return error;
}