]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
do_mq_notify(): switch to CLASS(fd)
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 1 Jun 2024 04:48:50 +0000 (00:48 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 3 Nov 2024 06:28:06 +0000 (01:28 -0500)
The only failure exit before fdget() is a return, the only thing done
after fdput() is transposable with it.

Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
ipc/mqueue.c

index 48640a36263797ba7911c4c07d892d62e6b1a601..4f1dec518fae7f7db9a70129d0eb82685cfe15c2 100644 (file)
@@ -1317,7 +1317,6 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
 static int do_mq_notify(mqd_t mqdes, const struct sigevent *notification)
 {
        int ret;
-       struct fd f;
        struct sock *sock;
        struct inode *inode;
        struct mqueue_inode_info *info;
@@ -1370,8 +1369,8 @@ retry:
                }
        }
 
-       f = fdget(mqdes);
-       if (!fd_file(f)) {
+       CLASS(fd, f)(mqdes);
+       if (fd_empty(f)) {
                ret = -EBADF;
                goto out;
        }
@@ -1379,7 +1378,7 @@ retry:
        inode = file_inode(fd_file(f));
        if (unlikely(fd_file(f)->f_op != &mqueue_file_operations)) {
                ret = -EBADF;
-               goto out_fput;
+               goto out;
        }
        info = MQUEUE_I(inode);
 
@@ -1418,8 +1417,6 @@ retry:
                inode_set_atime_to_ts(inode, inode_set_ctime_current(inode));
        }
        spin_unlock(&info->lock);
-out_fput:
-       fdput(f);
 out:
        if (sock)
                netlink_detachskb(sock, nc);