iommu: Check dev->iommu in dev_iommu_priv_get() before dereferencing it
The dev_iommu_priv_get() needs a similar check to
dev_iommu_fwspec_get() to make sure no NULL-ptr is dereferenced.
Fixes: 05a0542b45
("iommu/amd: Store dev_data as device iommu private data")
Cc: stable@vger.kernel.org # v5.8+
Link: https://lore.kernel.org/r/20210202145419.29143-1-joro@8bytes.org
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=211241
Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
1048ba83fb
commit
4c9fb5d914
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue