aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2025-07-12 06:41:57 +0100
committerChristian Brauner <brauner@kernel.org>2025-07-14 10:22:47 +0200
commit1f531e35c146cca22dc6f4a1bc657098f146f358 (patch)
treeb70d2dd3770c2910cfabe596c365eb29a2a3052b
parentfold fs_struct->{lock,seq} into a seqlock (diff)
downloadwireguard-linux-1f531e35c146cca22dc6f4a1bc657098f146f358.tar.xz
wireguard-linux-1f531e35c146cca22dc6f4a1bc657098f146f358.zip
don't bother with path_get()/path_put() in unix_open_file()
Once unix_sock ->path is set, we are guaranteed that its ->path will remain unchanged (and pinned) until the socket is closed. OTOH, dentry_open() does not modify the path passed to it. IOW, there's no need to copy unix_sk(sk)->path in unix_open_file() - we can just pass it to dentry_open() and be done with that. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Link: https://lore.kernel.org/20250712054157.GZ1880847@ZenIV Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
-rw-r--r--net/unix/af_unix.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index d52811321fce..c247fb9ac761 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -3201,7 +3201,6 @@ EXPORT_SYMBOL_GPL(unix_outq_len);
static int unix_open_file(struct sock *sk)
{
- struct path path;
struct file *f;
int fd;
@@ -3211,27 +3210,20 @@ static int unix_open_file(struct sock *sk)
if (!smp_load_acquire(&unix_sk(sk)->addr))
return -ENOENT;
- path = unix_sk(sk)->path;
- if (!path.dentry)
+ if (!unix_sk(sk)->path.dentry)
return -ENOENT;
- path_get(&path);
-
fd = get_unused_fd_flags(O_CLOEXEC);
if (fd < 0)
- goto out;
+ return fd;
- f = dentry_open(&path, O_PATH, current_cred());
+ f = dentry_open(&unix_sk(sk)->path, O_PATH, current_cred());
if (IS_ERR(f)) {
put_unused_fd(fd);
- fd = PTR_ERR(f);
- goto out;
+ return PTR_ERR(f);
}
fd_install(fd, f);
-out:
- path_put(&path);
-
return fd;
}