diff options
| author | Joerg Roedel <jroedel@suse.de> | 2021-02-02 15:54:19 +0100 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-02-10 09:29:17 +0100 |
| commit | e2bb221a16ac90a98c4fd2a6a4e0e096cba3bd45 (patch) | |
| tree | fcf743883b6e30801337bbb536b7e56c566218a0 /include/linux | |
| parent | 7a3361e5ecf16c072609bfae898d1e9061552ed9 (diff) | |
iommu: Check dev->iommu in dev_iommu_priv_get() before dereferencing it
commit 4c9fb5d9140802db4db9f66c23887f43174e113c upstream.
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")
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/iommu.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/include/linux/iommu.h b/include/linux/iommu.h index b95a6f8db6ff..9bbcfe3b0bb1 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -614,7 +614,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) |
