[SRU][N:linux-bluefield][PATCH v1 1/1] UBUNTU: SAUCE: Fix vfio_pci_core_ioctl compilation issue
Stav Aviram
saviram at nvidia.com
Thu Oct 23 14:32:56 UTC 2025
BugLink: https://bugs.launchpad.net/bugs/2129689
Fix compilation error on x86_64 caused by a C standards violation in
the VFIO_DEVICE_P2P_DMA_BUF case handler.
During the port of commit 60da28814250 ("vfio/pci: Allow MMIO regions
to be exported through dma-buf") from linux-bluefield-5.15 to 6.8, the
vfio_pci_core_ioctl function structure changed from an if-else chain to
a switch statement. The adaptation converted the original
'else if (cmd == VFIO_DEVICE_P2P_DMA_BUF)' to a case label but did not
add the necessary braces around the case block.
In C, a case label cannot be directly followed by a variable declaration
without an intervening compound statement. This violates C language
standards (C89/C90/C99/C11), causing compilation failures on x86_64 with
certain compiler configurations:
drivers/vfio/pci/vfio_pci_core.c:1489:3: error: a label can only be
part of a statement and a declaration is not a statement
The fix adds braces to create a compound statement around the case block,
making the code standards-compliant without changing any logic.
Fixes: 60da28814250 ("vfio/pci: Allow MMIO regions to be exported through dma-buf")
Signed-off-by: Stav Aviram <saviram at nvidia.com>
---
drivers/vfio/pci/vfio_pci_core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
index d015e65ef988..40fc0607e45f 100644
--- a/drivers/vfio/pci/vfio_pci_core.c
+++ b/drivers/vfio/pci/vfio_pci_core.c
@@ -1485,13 +1485,14 @@ long vfio_pci_core_ioctl(struct vfio_device *core_vdev, unsigned int cmd,
return vfio_pci_ioctl_reset(vdev, uarg);
case VFIO_DEVICE_SET_IRQS:
return vfio_pci_ioctl_set_irqs(vdev, uarg);
- case VFIO_DEVICE_P2P_DMA_BUF:
+ case VFIO_DEVICE_P2P_DMA_BUF: {
struct vfio_device_p2p_dma_buf p2p_dma_buf;
if (copy_from_user(&p2p_dma_buf, uarg, sizeof(p2p_dma_buf)))
return -EFAULT;
return vfio_pci_core_feature_dma_buf(vdev, &p2p_dma_buf);
+ }
default:
return -ENOTTY;
}
--
2.38.1
More information about the kernel-team
mailing list