Skip to content

Commit 5748346

Browse files
author
Al Viro
committed
chroot(2): switch to CLASS(filename)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent cbe9e30 commit 5748346

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

fs/open.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,11 @@ SYSCALL_DEFINE1(chroot, const char __user *, filename)
592592
struct path path;
593593
int error;
594594
unsigned int lookup_flags = LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
595-
struct filename *name = getname(filename);
595+
CLASS(filename, name)(filename);
596596
retry:
597597
error = filename_lookup(AT_FDCWD, name, lookup_flags, &path, NULL);
598598
if (error)
599-
goto out;
599+
return error;
600600

601601
error = path_permission(&path, MAY_EXEC | MAY_CHDIR);
602602
if (error)
@@ -606,19 +606,14 @@ SYSCALL_DEFINE1(chroot, const char __user *, filename)
606606
if (!ns_capable(current_user_ns(), CAP_SYS_CHROOT))
607607
goto dput_and_out;
608608
error = security_path_chroot(&path);
609-
if (error)
610-
goto dput_and_out;
611-
612-
set_fs_root(current->fs, &path);
613-
error = 0;
609+
if (!error)
610+
set_fs_root(current->fs, &path);
614611
dput_and_out:
615612
path_put(&path);
616613
if (retry_estale(error, lookup_flags)) {
617614
lookup_flags |= LOOKUP_REVAL;
618615
goto retry;
619616
}
620-
out:
621-
putname(name);
622617
return error;
623618
}
624619

0 commit comments

Comments
 (0)