Re: [PATCH v3 1/2] vfio: Fix unbalanced vfio_df_close call in no-iommu mode
From: Jason Gunthorpe
Date: Thu Jun 19 2025 - 14:59:35 EST
On Wed, Jun 18, 2025 at 04:46:17PM -0700, Jacob Pan wrote:
> For devices with no-iommu enabled in IOMMUFD VFIO compat mode, the group open
> path skips vfio_df_open(), leaving open_count at 0. This causes a warning in
> vfio_assert_device_open(device) when vfio_df_close() is called during group
> close.
>
> The correct behavior is to skip only the IOMMUFD bind in the device open path
> for no-iommu devices. Commit 6086efe73498 omitted vfio_df_open(), which was
> too broad. This patch restores the previous behavior, ensuring
> the vfio_df_open is called in the group open path.
>
> Fixes: 6086efe73498 ("vfio-iommufd: Move noiommu compat validation out of vfio_iommufd_bind()")
> Suggested-by: Alex Williamson <alex.williamson@xxxxxxxxxx>
> Suggested-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
> Signed-off-by: Jacob Pan <jacob.pan@xxxxxxxxxxxxxxxxxxx>
> ---
> v3: Apply a concise fix from Alex
> v2: Use a fix from Jason
> ---
> drivers/vfio/group.c | 7 +++----
> drivers/vfio/iommufd.c | 4 ++++
> 2 files changed, 7 insertions(+), 4 deletions(-)
Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
Jason