diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2025-08-21 22:40:14 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2025-09-02 19:35:58 -0400 |
| commit | 6bbbc4a04a10ebdb633501dc87aac5b0d6b80ec8 (patch) | |
| tree | 5a7778cf35dbc2e6e182a066255d91dc4cdf8e7f /fs/namespace.c | |
| parent | 76dfde13d68a2a6e6c2409407558ee908491df36 (diff) | |
pivot_root(2): use __free() to deal with struct path in it
preparations for making unlock_mount() a __cleanup();
can't have path_put() inside mount_lock scope.
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namespace.c')
| -rw-r--r-- | fs/namespace.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index 245cf2d19a6b..90b62ee882da 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -4622,7 +4622,9 @@ EXPORT_SYMBOL(path_is_under); SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, const char __user *, put_old) { - struct path new, old, root; + struct path new __free(path_put) = {}; + struct path old __free(path_put) = {}; + struct path root __free(path_put) = {}; struct mount *new_mnt, *root_mnt, *old_mnt, *root_parent, *ex_parent; struct pinned_mountpoint old_mp = {}; int error; @@ -4633,21 +4635,21 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, error = user_path_at(AT_FDCWD, new_root, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &new); if (error) - goto out0; + return error; error = user_path_at(AT_FDCWD, put_old, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &old); if (error) - goto out1; + return error; error = security_sb_pivotroot(&old, &new); if (error) - goto out2; + return error; get_fs_root(current->fs, &root); error = lock_mount(&old, &old_mp); if (error) - goto out3; + return error; error = -EINVAL; new_mnt = real_mount(new.mnt); @@ -4705,13 +4707,6 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, error = 0; out4: unlock_mount(&old_mp); -out3: - path_put(&root); -out2: - path_put(&old); -out1: - path_put(&new); -out0: return error; } |