summaryrefslogtreecommitdiffstats
path: root/drivers/iommu/intel/irq_remapping.c
diff options
context:
space:
mode:
authorDinghao Liu <dinghao.liu@zju.edu.cn>2021-01-05 06:18:37 +0100
committerWill Deacon <will@kernel.org>2021-01-05 20:12:06 +0100
commitff2b46d7cff80d27d82f7f3252711f4ca1666129 (patch)
treed989290638769cca3becd7c334e8e12e4b73c9ed /drivers/iommu/intel/irq_remapping.c
parentiommu/iova: fix 'domain' typos (diff)
downloadlinux-ff2b46d7cff80d27d82f7f3252711f4ca1666129.tar.xz
linux-ff2b46d7cff80d27d82f7f3252711f4ca1666129.zip
iommu/intel: Fix memleak in intel_irq_remapping_alloc
When irq_domain_get_irq_data() or irqd_cfg() fails at i == 0, data allocated by kzalloc() has not been freed before returning, which leads to memleak. Fixes: b106ee63abcc ("irq_remapping/vt-d: Enhance Intel IR driver to support hierarchical irqdomains") Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn> Acked-by: Lu Baolu <baolu.lu@linux.intel.com> Link: https://lore.kernel.org/r/20210105051837.32118-1-dinghao.liu@zju.edu.cn Signed-off-by: Will Deacon <will@kernel.org>
Diffstat (limited to 'drivers/iommu/intel/irq_remapping.c')
-rw-r--r--drivers/iommu/intel/irq_remapping.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/iommu/intel/irq_remapping.c b/drivers/iommu/intel/irq_remapping.c
index aeffda92b10b..685200a5cff0 100644
--- a/drivers/iommu/intel/irq_remapping.c
+++ b/drivers/iommu/intel/irq_remapping.c
@@ -1353,6 +1353,8 @@ static int intel_irq_remapping_alloc(struct irq_domain *domain,
irq_data = irq_domain_get_irq_data(domain, virq + i);
irq_cfg = irqd_cfg(irq_data);
if (!irq_data || !irq_cfg) {
+ if (!i)
+ kfree(data);
ret = -EINVAL;
goto out_free_data;
}