提交 b72e728b 编写于 作者: J Jon Derrick 提交者: Yang Yingliang

iommu/vt-d: Unlink device if failed to add to group

mainline inclusion
from mainline-v5.5-rc6
commit f78947c4
category: bugfix
bugzilla: 96934
CVE: NA

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

If the device fails to be added to the group, make sure to unlink the
reference before returning.
Signed-off-by: NJon Derrick <jonathan.derrick@intel.com>
Fixes: 39ab9555 ("iommu: Add sysfs bindings for struct iommu_device")
Acked-by: NLu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: NJoerg Roedel <jroedel@suse.de>

Conflict:
	drivers/iommu/intel-iommu.c
Signed-off-by: NNanyong Sun <sunnanyong@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 fe532395
......@@ -5239,6 +5239,7 @@ static int intel_iommu_add_device(struct device *dev)
struct intel_iommu *iommu;
struct iommu_group *group;
u8 bus, devfn;
int ret;
iommu = device_to_iommu(dev, &bus, &devfn);
if (!iommu)
......@@ -5248,11 +5249,17 @@ static int intel_iommu_add_device(struct device *dev)
group = iommu_group_get_for_dev(dev);
if (IS_ERR(group))
return PTR_ERR(group);
if (IS_ERR(group)) {
ret = PTR_ERR(group);
goto unlink;
}
iommu_group_put(group);
return 0;
unlink:
iommu_device_unlink(&iommu->iommu, dev);
return ret;
}
static void intel_iommu_remove_device(struct device *dev)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册