提交 c4a783b8 编写于 作者: J Joerg Roedel

iommu/core: Make iommu_group_get_for_dev() more robust

When a non-PCI device is passed to that function it might
pass group == NULL to iommu_group_add_device() which then
dereferences it and cause a crash this way. Fix it by
just returning an error for non-PCI devices.

Fixes: 104a1c13
Cc: Alex Williamson <alex.williamson@redhat.com>
Acked-by: NAlex Williamson <alex.williamson@redhat.com>
Signed-off-by: NJoerg Roedel <jroedel@suse.de>
上级 52addcf9
...@@ -678,15 +678,17 @@ static struct iommu_group *iommu_group_get_for_pci_dev(struct pci_dev *pdev) ...@@ -678,15 +678,17 @@ static struct iommu_group *iommu_group_get_for_pci_dev(struct pci_dev *pdev)
*/ */
struct iommu_group *iommu_group_get_for_dev(struct device *dev) struct iommu_group *iommu_group_get_for_dev(struct device *dev)
{ {
struct iommu_group *group = ERR_PTR(-EIO); struct iommu_group *group;
int ret; int ret;
group = iommu_group_get(dev); group = iommu_group_get(dev);
if (group) if (group)
return group; return group;
if (dev_is_pci(dev)) if (!dev_is_pci(dev))
group = iommu_group_get_for_pci_dev(to_pci_dev(dev)); return ERR_PTR(-EINVAL);
group = iommu_group_get_for_pci_dev(to_pci_dev(dev));
if (IS_ERR(group)) if (IS_ERR(group))
return group; return group;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册