Re: [PATCH V4 4/9] mshv: Add ioctl support for MSHV-VFIO bridge device
From: Jacob Pan
Date: Fri Jul 24 2026 - 13:27:17 EST
Hi Mukesh,
On Fri, 17 Jul 2026 19:19:44 -0700
Mukesh R <mrathor@xxxxxxxxxxxxxxxxxxx> wrote:
> + hlist_add_head(&mshv_dev->device_ptnode,
> &partition->pt_devices); +
> + mshv_partition_get(partition);
> + rc = anon_inode_getfd(vfio_ops->device_name,
> &mshv_device_fops,
> + mshv_dev, O_RDWR | O_CLOEXEC);
> + if (rc < 0)
> + goto undo_out;
> +
> + devargk.fd = rc;
> + if (copy_to_user(uarg, &devargk, sizeof(devargk)))
> + return -EFAULT; /* cleanup in
> mshv_device_fop_release() */ +
In failure, user never gets the fd, so it never close it. We are leaking
fd until process exit, right?
Maybe we should do anon_inode_getfile(...) and do fd_install() only if
copy_to_user succeeds.
Thanks,
Jacob