]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
iommu/intel: Fix memleak in intel_irq_remapping_alloc
authorDinghao Liu <dinghao.liu@zju.edu.cn>
Tue, 5 Jan 2021 05:18:37 +0000 (13:18 +0800)
committerWill Deacon <will@kernel.org>
Tue, 5 Jan 2021 19:12:06 +0000 (19:12 +0000)
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>
drivers/iommu/intel/irq_remapping.c

index aeffda92b10b76058e2ef11a8b6d1319ddfb72d8..685200a5cff0f30578d847e3915aa5179fb66e7d 100644 (file)
@@ -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;
                }