All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [v2] iommu/intel: Fix memleak in intel_irq_remapping_alloc
@ 2021-01-05  5:18 ` Dinghao Liu
  0 siblings, 0 replies; 6+ messages in thread
From: Dinghao Liu @ 2021-01-05  5:18 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: David Woodhouse, Lu Baolu, Joerg Roedel, Will Deacon,
	Thomas Gleixner, Jiang Liu, iommu, linux-kernel

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: b106ee63abccb ("irq_remapping/vt-d: Enhance Intel IR driver to support hierarchical irqdomains")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---

Changelog:

v2: - Add a check against i instead of setting data to NULL.
---
 drivers/iommu/intel/irq_remapping.c | 2 ++
 1 file changed, 2 insertions(+)

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;
 		}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-05 22:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-05  5:18 [PATCH] [v2] iommu/intel: Fix memleak in intel_irq_remapping_alloc Dinghao Liu
2021-01-05  5:18 ` Dinghao Liu
2021-01-05  8:38 ` Lu Baolu
2021-01-05  8:38   ` Lu Baolu
2021-01-05 22:07 ` Will Deacon
2021-01-05 22:07   ` Will Deacon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.