]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mshv_eventfd: convert to CLASS(fd)
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 12 Jul 2025 16:48:12 +0000 (12:48 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 16 Jul 2025 05:45:06 +0000 (01:45 -0400)
similar to 66635b077624 ("assorted variants of irqfd setup: convert
to CLASS(fd)") a year ago...

Acked-by: Wei Liu <wei.liu@kernel.org>
Reviewed-by: Nuno Das Neves <nunodasneves@linux.microsoft.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
drivers/hv/mshv_eventfd.c

index 8dd22be2ca0b4c6c8e78df28429d33d9893285de..48c514da34eb0bed75fc2d63c26d0b2d34b96406 100644 (file)
@@ -377,10 +377,11 @@ static int mshv_irqfd_assign(struct mshv_partition *pt,
        struct eventfd_ctx *eventfd = NULL, *resamplefd = NULL;
        struct mshv_irqfd *irqfd, *tmp;
        unsigned int events;
-       struct fd f;
        int ret;
        int idx;
 
+       CLASS(fd, f)(args->fd);
+
        irqfd = kzalloc(sizeof(*irqfd), GFP_KERNEL);
        if (!irqfd)
                return -ENOMEM;
@@ -390,8 +391,7 @@ static int mshv_irqfd_assign(struct mshv_partition *pt,
        INIT_WORK(&irqfd->irqfd_shutdown, mshv_irqfd_shutdown);
        seqcount_spinlock_init(&irqfd->irqfd_irqe_sc, &pt->pt_irqfds_lock);
 
-       f = fdget(args->fd);
-       if (!fd_file(f)) {
+       if (fd_empty(f)) {
                ret = -EBADF;
                goto out;
        }
@@ -496,12 +496,6 @@ static int mshv_irqfd_assign(struct mshv_partition *pt,
                mshv_assert_irq_slow(irqfd);
 
        srcu_read_unlock(&pt->pt_irq_srcu, idx);
-       /*
-        * do not drop the file until the irqfd is fully initialized, otherwise
-        * we might race against the POLLHUP
-        */
-       fdput(f);
-
        return 0;
 
 fail:
@@ -514,8 +508,6 @@ fail:
        if (eventfd && !IS_ERR(eventfd))
                eventfd_ctx_put(eventfd);
 
-       fdput(f);
-
 out:
        kfree(irqfd);
        return ret;