提交 e47576bc 编写于 作者: J Joerg Roedel 提交者: Zheng Zengkai

iommu: Check dev->iommu in dev_iommu_priv_get() before dereferencing it

stable inclusion
from stable-5.10.15
commit e2bb221a16ac90a98c4fd2a6a4e0e096cba3bd45
bugzilla: 48167

--------------------------------

commit 4c9fb5d9 upstream.

The dev_iommu_priv_get() needs a similar check to
dev_iommu_fwspec_get() to make sure no NULL-ptr is dereferenced.

Fixes: 05a0542b ("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=211241Signed-off-by: NJoerg Roedel <jroedel@suse.de>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 1fe91995
...@@ -614,7 +614,10 @@ static inline void dev_iommu_fwspec_set(struct device *dev, ...@@ -614,7 +614,10 @@ static inline void dev_iommu_fwspec_set(struct device *dev,
static inline void *dev_iommu_priv_get(struct device *dev) static inline void *dev_iommu_priv_get(struct device *dev)
{ {
if (dev->iommu)
return dev->iommu->priv; return dev->iommu->priv;
else
return NULL;
} }
static inline void dev_iommu_priv_set(struct device *dev, void *priv) static inline void dev_iommu_priv_set(struct device *dev, void *priv)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册