[PATCH v2] KVM: vfio: Convert fget() to CLASS(fd) in kvm_vfio_file_add()
From: Yash Suthar
Date: Mon Jun 15 2026 - 08:06:21 EST
Convert fget() with __free(fput) cleanup to CLASS(fd, f),
using fd_empty() and fd_file().
Signed-off-by: Yash Suthar <yashsuthar983@xxxxxxxxx>
---
virt/kvm/vfio.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/virt/kvm/vfio.c b/virt/kvm/vfio.c
index 6cdc4e9a333a..bbd7a5dfb76e 100644
--- a/virt/kvm/vfio.c
+++ b/virt/kvm/vfio.c
@@ -144,12 +144,14 @@ static int kvm_vfio_file_add(struct kvm_device *dev, unsigned int fd)
{
struct kvm_vfio *kv = dev->private;
struct kvm_vfio_file *kvf;
- struct file *filp __free(fput) = NULL;
+ CLASS(fd, f)(fd);
+ struct file *filp = NULL;
- filp = fget(fd);
- if (!filp)
+ if (fd_empty(f))
return -EBADF;
+ filp = fd_file(f);
+
/* Ensure the FD is a vfio FD. */
if (!kvm_vfio_file_is_valid(filp))
return -EINVAL;
--
2.43.0