Commit 2cf4be57b301 for kernel
commit 2cf4be57b301ed2d7af82e70cff5dfd96894d8de
Author: Jean-Christophe Guillain <jean-christophe@guillain.net>
Date: Thu Nov 5 16:32:19 2026 +0000
iommu/amd: Fix NULL pointer dereference for GPUs without upstream bridge
pci_upstream_bridge() can return NULL for devices without an upstream
bridge. The AMD GPU identity mapping quirk dereferences the returned
pointer unconditionally, causing a kernel panic during boot.
Check the pointer before accessing the bridge vendor ID.
This fixes a boot regression on a Lenovo system with an AMD PRO
A10-9700E APU. The system now boots with AMD IOMMU enabled.
Fixes: bf5bdfd1f8d4 ("iommu/amd: Force identity mode for selected GPUs only")
Signed-off-by: Jean-Christophe Guillain <jean-christophe@guillain.net>
Signed-off-by: Vasant Hegde <vasant.hegde@amd.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 91981c8a9614..41ee4ad1dcf8 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -3191,6 +3191,7 @@ static bool amd_iommu_is_attach_deferred(struct device *dev)
static bool quirks_force_identity_mapping(struct pci_dev *pdev)
{
+ struct pci_dev *bridge;
int class = pdev->class >> 8;
/* AMD GPU vendor ID */
@@ -3202,7 +3203,8 @@ static bool quirks_force_identity_mapping(struct pci_dev *pdev)
class != PCI_CLASS_DISPLAY_OTHER)
return false;
- if (pci_upstream_bridge(pdev)->vendor == PCI_VENDOR_ID_ATI)
+ bridge = pci_upstream_bridge(pdev);
+ if (bridge && bridge->vendor == PCI_VENDOR_ID_ATI)
return false;
/* It is the GPU in an APU, force identity domain */