mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] iommu/amd: Fix leak of data->entry in irq_remapping_alloc() error path
@ 2026-09-22  9:00 lirongqing
  2026-09-24 12:04 ` Joerg Roedel
  0 siblings, 1 reply; 2+ messages in thread
From: lirongqing @ 2026-09-22  9:00 UTC (permalink / raw)
  To: Joerg Roedel, Suravee Suthikulpanit, Vasant Hegde, Will Deacon,
	Robin Murphy, iommu, linux-kernel
  Cc: Li RongQing

From: Li RongQing <lirongqing@baidu.com>

In irq_remapping_alloc() each per-IRQ iteration allocates two objects:
the amd_ir_data (chip_data) and its data->entry (union irte / struct
irte_ga). The out_free_data error path only freed chip_data via
kfree(irq_data->chip_data), leaking data->entry for every already
initialized IRQ.

Free data->entry alongside data on the error path.

Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 drivers/iommu/amd/iommu.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index fd27373..92e93d2 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -3906,8 +3906,11 @@ static int irq_remapping_alloc(struct irq_domain *domain, unsigned int virq,
 out_free_data:
 	for (i--; i >= 0; i--) {
 		irq_data = irq_domain_get_irq_data(domain, virq + i);
-		if (irq_data)
-			kfree(irq_data->chip_data);
+		if (irq_data && irq_data->chip_data) {
+			data = irq_data->chip_data;
+			kfree(data->entry);
+			kfree(data);
+		}
 	}
 	for (i = 0; i < nr_irqs; i++)
 		free_irte(iommu, devid, index + i);
-- 
2.9.4


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

end of thread, other threads:[~2026-09-24 12:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-22  9:00 [PATCH] iommu/amd: Fix leak of data->entry in irq_remapping_alloc() error path lirongqing
2026-09-24 12:04 ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®