From d615131f8d789788d8b014a8addc41a4089b6c64 Mon Sep 17 00:00:00 2001 From: LeoLiu-oc Date: Mon, 20 Oct 2025 15:39:46 +0800 Subject: [PATCH] iommu/vt-d: fix NULL pointer issue in acpi_rmrr_andd_probe zhaoxin inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/ID2O03 CVE: NA ------------------- When the dev->iommu was NULL for the RMRR ANDD device, the corresponding (&pci_device->dev)->iommu could be used instead. Reviewed-by: Yee Li Tested-by: Lyle Li Signed-off-by: LeoLiu-oc --- drivers/iommu/dma-iommu.c | 6 ++++++ drivers/iommu/intel/iommu.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index b8258a474edf..7c8ca30be297 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -591,6 +591,12 @@ int iova_reserve_domain_addr(struct iommu_domain *domain, dma_addr_t start, dma_ unsigned long lo, hi; + if (!iovad->granule) { + unsigned long order = __ffs(domain->pgsize_bitmap); + + iovad->granule = 1UL << order; + } + lo = iova_pfn(iovad, start); hi = iova_pfn(iovad, end); diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index bb23fc0f4832..f6f23375206c 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -3652,6 +3652,10 @@ static inline int acpi_rmrr_andd_probe(struct device *dev) pr_err("cannot get acpi devie corresponding pci_device\n"); return -EINVAL; } + + if (!dev->iommu) + dev->iommu = (&pci_device->dev)->iommu; + ret = acpi_rmrr_device_create_direct_mappings(iommu_get_domain_for_dev(&pci_device->dev), dev); -- Gitee