Re: [PATCH v2 2/2] vfio: Fix unbalanced vfio_df_close call in no-iommu mode

From: Jacob Pan
Date: Wed Jun 18 2025 - 19:11:44 EST


Hi Jason,

On Mon, 16 Jun 2025 17:05:58 -0300
Jason Gunthorpe <jgg@xxxxxxxxxx> wrote:

> On Mon, Jun 16, 2025 at 01:40:04PM -0600, Alex Williamson wrote:
> > --- a/drivers/vfio/group.c
> > +++ b/drivers/vfio/group.c
> > @@ -192,18 +192,18 @@ static int vfio_df_group_open(struct
> > vfio_device_file *df)
> > * implies they expected translation to exist
> > */
> > if (!capable(CAP_SYS_RAWIO) ||
> > - vfio_iommufd_device_has_compat_ioas(device,
> > df->iommufd))
> > + vfio_iommufd_device_has_compat_ioas(device,
> > df->iommufd)) { ret = -EPERM;
> > - else
> > - ret = 0;
> > - goto out_put_kvm;
> > + goto out_put_kvm;
> > + }
> > }
> >
> >
> > And add a noiommu exit branch to _iommufd_bind, symmetric to unbind.
> > Right? Thanks,
>
> Just comparing to the original
>
> + if (iommufd) {
> + if (!vfio_device_is_noiommu(device))
> + ret = vfio_df_iommufd_bind(df);
>
> Isn't being captured, so it needs another hunk in
> vfio_df_iommufd_bind()
>
OK, will send out v3 with this concise fix. I am also working on the
noiommu special mode as you suggested, then we can allow bind again.

Thanks,

Jacob