* [PATCH] iommu: Check dev->iommu in dev_iommu_priv_get() before dereferencing it
@ 2021-02-02 14:54 Joerg Roedel
0 siblings, 0 replies; only message in thread
From: Joerg Roedel @ 2021-02-02 14:54 UTC (permalink / raw)
To: iommu; +Cc: linux-kernel, Joerg Roedel, stable
From: Joerg Roedel <jroedel@suse.de>
The dev_iommu_priv_get() needs a similar check to
dev_iommu_fwspec_get() to make sure no NULL-ptr is dereferenced.
Fixes: 05a0542b456e1 ("iommu/amd: Store dev_data as device iommu private data")
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=211241
Cc: stable@vger.kernel.org # v5.8+
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
include/linux/iommu.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 524ffc2ff64f..5b3a7a08dc70 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -616,7 +616,10 @@ static inline void dev_iommu_fwspec_set(struct device *dev,
static inline void *dev_iommu_priv_get(struct device *dev)
{
- return dev->iommu->priv;
+ if (dev->iommu)
+ return dev->iommu->priv;
+ else
+ return NULL;
}
static inline void dev_iommu_priv_set(struct device *dev, void *priv)
--
2.30.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-02-02 14:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02 14:54 [PATCH] iommu: Check dev->iommu in dev_iommu_priv_get() before dereferencing it Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®