[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <5481021644415780@myt5-a5512e99e394.qloud-c.yandex.net>
Date: Wed, 09 Feb 2022 17:09:40 +0300
From: Aleksandr Fedorov <sanekf@....ru>
To: Joerg Roedel <joro@...tes.org>, Will Deacon <will@...nel.org>,
iommu@...ts.linux-foundation.org, linux-kernel@...r.kernel.org
Subject: [PATCH] iommu: explicitly check for NULL in iommu_dma_get_resv_regions()
iommu_dma_get_resv_regions() assumes that iommu_fwspec field for
corresponding device is set which is not always true. Since
iommu_dma_get_resv_regions() seems to be a future-proof generic API
that can be used by any iommu driver, add an explicit check for NULL.
Currently it can work by accident since compiler can eliminate
the 'iommu_fwspec' check altogether when CONFIG_ACPI_IORT=n, but
code elimination from optimizations is not reliable.
Signed-off-by: Aleksandr Fedorov <halcien@...il.com>
---
A compilation failure has been observed on a gcc-compatible compiler based on EDG.
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index d85d54f2b549..474b1b7211d7 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -382,10 +382,10 @@ void iommu_put_dma_cookie(struct iommu_domain *domain)
*/
void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list)
{
+ struct iommu_fwspec *iommu_fwspec = dev_iommu_fwspec_get(dev);
- if (!is_of_node(dev_iommu_fwspec_get(dev)->iommu_fwnode))
+ if (iommu_fwspec && !is_of_node(iommu_fwspec->iommu_fwnode))
iort_iommu_msi_get_resv_regions(dev, list);
-
}
EXPORT_SYMBOL(iommu_dma_get_resv_regions);
Powered by blists - more mailing lists