Signed-off-by: Christian Brauner --- net/unix/af_unix.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 68c94f49f7b5..6de7909182ee 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -3277,9 +3277,6 @@ EXPORT_SYMBOL_GPL(unix_outq_len); static int unix_open_file(struct sock *sk) { - struct file *f; - int fd; - if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) return -EPERM; @@ -3289,18 +3286,7 @@ static int unix_open_file(struct sock *sk) if (!unix_sk(sk)->path.dentry) return -ENOENT; - fd = get_unused_fd_flags(O_CLOEXEC); - if (fd < 0) - return fd; - - f = dentry_open(&unix_sk(sk)->path, O_PATH, current_cred()); - if (IS_ERR(f)) { - put_unused_fd(fd); - return PTR_ERR(f); - } - - fd_install(fd, f); - return fd; + return FD_ADD(O_CLOEXEC, dentry_open(&unix_sk(sk)->path, O_PATH, current_cred())); } static int unix_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) -- 2.47.3