diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2024-07-14 21:49:04 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2024-11-03 01:28:06 -0500 |
commit | f302edb9d822804e72df3fa6ba270234050c678b (patch) | |
tree | 01ba6ce53daa3bb3a604fdef197802a7b58fa3a2 /net/netlink | |
parent | 4dd53b84ff23424e2fe1e902decacdb49303e3d3 (diff) | |
download | linux-f302edb9d822804e72df3fa6ba270234050c678b.tar.gz linux-f302edb9d822804e72df3fa6ba270234050c678b.tar.bz2 linux-f302edb9d822804e72df3fa6ba270234050c678b.zip |
switch netlink_getsockbyfilp() to taking descriptor
the only call site (in do_mq_notify()) obtains the argument
from an immediately preceding fdget() and it is immediately
followed by fdput(); might as well just replace it with
a variant that would take a descriptor instead of struct file *
and have file lookups handled inside that function.
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'net/netlink')
-rw-r--r-- | net/netlink/af_netlink.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 0b7a89db3ab7..42451ac355d0 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -1180,11 +1180,16 @@ static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid) return sock; } -struct sock *netlink_getsockbyfilp(struct file *filp) +struct sock *netlink_getsockbyfd(int fd) { - struct inode *inode = file_inode(filp); + CLASS(fd, f)(fd); + struct inode *inode; struct sock *sock; + if (fd_empty(f)) + return ERR_PTR(-EBADF); + + inode = file_inode(fd_file(f)); if (!S_ISSOCK(inode->i_mode)) return ERR_PTR(-ENOTSOCK); |