提交 75624b5b 编写于 作者: G Guoqing Jiang 提交者: Laibin Qiu

iommu/vt-d: Fix potential memory leak in intel_setup_irq_remapping()

stable inclusion
from linux-4.19.228
commit a31cb1f0fb6caf46ffe88c41252b6b7a4ee062d9

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

commit 99e675d4 upstream.

After commit e3beca48 ("irqdomain/treewide: Keep firmware node
unconditionally allocated"). For tear down scenario, fn is only freed
after fail to allocate ir_domain, though it also should be freed in case
dmar_enable_qi returns error.

Besides free fn, irq_domain and ir_msi_domain need to be removed as well
if intel_setup_irq_remapping fails to enable queued invalidation.

Improve the rewinding path by add out_free_ir_domain and out_free_fwnode
lables per Baolu's suggestion.

Fixes: e3beca48 ("irqdomain/treewide: Keep firmware node unconditionally allocated")
Suggested-by: NLu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: NGuoqing Jiang <guoqing.jiang@linux.dev>
Link: https://lore.kernel.org/r/20220119063640.16864-1-guoqing.jiang@linux.devSigned-off-by: NLu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/20220128031002.2219155-3-baolu.lu@linux.intel.comSigned-off-by: NJoerg Roedel <jroedel@suse.de>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
Signed-off-by: NLaibin Qiu <qiulaibin@huawei.com>
上级 f4af292a
...@@ -539,7 +539,7 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu) ...@@ -539,7 +539,7 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
irq_domain_free_fwnode(fn); irq_domain_free_fwnode(fn);
if (!iommu->ir_domain) { if (!iommu->ir_domain) {
pr_err("IR%d: failed to allocate irqdomain\n", iommu->seq_id); pr_err("IR%d: failed to allocate irqdomain\n", iommu->seq_id);
goto out_free_bitmap; goto out_free_fwnode;
} }
iommu->ir_msi_domain = iommu->ir_msi_domain =
arch_create_remap_msi_irq_domain(iommu->ir_domain, arch_create_remap_msi_irq_domain(iommu->ir_domain,
...@@ -563,7 +563,7 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu) ...@@ -563,7 +563,7 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
if (dmar_enable_qi(iommu)) { if (dmar_enable_qi(iommu)) {
pr_err("Failed to enable queued invalidation\n"); pr_err("Failed to enable queued invalidation\n");
goto out_free_bitmap; goto out_free_ir_domain;
} }
} }
...@@ -587,6 +587,14 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu) ...@@ -587,6 +587,14 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
return 0; return 0;
out_free_ir_domain:
if (iommu->ir_msi_domain)
irq_domain_remove(iommu->ir_msi_domain);
iommu->ir_msi_domain = NULL;
irq_domain_remove(iommu->ir_domain);
iommu->ir_domain = NULL;
out_free_fwnode:
irq_domain_free_fwnode(fn);
out_free_bitmap: out_free_bitmap:
kfree(bitmap); kfree(bitmap);
out_free_pages: out_free_pages:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册