]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
vfio/cdx: Consolidate MSI configured state onto cdx_irqs
authorAlex Williamson <alex.williamson@nvidia.com>
Fri, 17 Apr 2026 20:27:58 +0000 (14:27 -0600)
committerAlex Williamson <alex@shazbot.org>
Tue, 21 Apr 2026 18:01:22 +0000 (12:01 -0600)
commit30471982cd667972ba93ce894765d4b8544958e6
tree3342c00e9db63d6763a9e4dc07906212c99de82c
parent670e8864b1a218d72f08db40d0103adf38fa1d9b
vfio/cdx: Consolidate MSI configured state onto cdx_irqs

struct vfio_cdx_device carries three fields that track whether MSI has
been configured: vdev->cdx_irqs (the allocated vector array), vdev->
msi_count (the array length), and vdev->config_msi (a boolean flag).
The three are set together when vfio_cdx_msi_enable() succeeds and
cleared together by vfio_cdx_msi_disable().  However, the error paths
in vfio_cdx_msi_enable() free the cdx_irqs allocation on failure
without resetting the pointer, leaving it stale and skewed from the
other two fields until the next enable call overwrites it.

Clear vdev->cdx_irqs to NULL alongside the kfree() in both error paths
so the pointer consistently reflects the configured state.  With that
invariant restored and access to the MSI state serialized by
cdx_irqs_lock, vdev->config_msi is fully redundant with
(vdev->cdx_irqs != NULL).  Drop the config_msi field and switch all
readers to test cdx_irqs directly.

Assisted-by: Claude:claude-opus-4-7
Signed-off-by: Alex Williamson <alex.williamson@nvidia.com>
Acked-by: Nikhil Agarwal <nikhil.agarwal@amd.com>
Link: https://lore.kernel.org/r/20260417202800.88287-4-alex.williamson@nvidia.com
Signed-off-by: Alex Williamson <alex@shazbot.org>
drivers/vfio/cdx/intr.c
drivers/vfio/cdx/private.h