[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240411105630.53865-1-guanrui.huang@linux.alibaba.com>
Date: Thu, 11 Apr 2024 18:56:30 +0800
From: Guanrui Huang <guanrui.huang@...ux.alibaba.com>
To: maz@...nel.org
Cc: yuzenghui@...wei.com,
shannon.zhao@...ux.alibaba.com,
tglx@...utronix.de,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
Guanrui Huang <guanrui.huang@...ux.alibaba.com>
Subject: [PATCH v2] irqchip/gic-v3-its: Fix double free on error
In its_vpe_irq_domain_alloc, when its_vpe_init() returns an error
with i > 0, its_vpe_irq_domain_free may free bitmap and vprop_page,
and then there is a double free in its_vpe_irq_domain_alloc.
Fix it by calling its_vpe_irq_domain_free directly, bitmap and
vprop_page will be freed in this function.
And check whether its_vm is equal to domain->host_data to make sure
its_vpe_irq_domain_free handle right its_vm.
Signed-off-by: Guanrui Huang <guanrui.huang@...ux.alibaba.com>
---
drivers/irqchip/irq-gic-v3-its.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index fca888b36680..72c44e555c88 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -4523,6 +4523,9 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq
BUG_ON(!vm);
+ if (vm != domain->host_data)
+ return -EINVAL;
+
bitmap = its_lpi_alloc(roundup_pow_of_two(nr_irqs), &base, &nr_ids);
if (!bitmap)
return -ENOMEM;
@@ -4561,13 +4564,8 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq
irqd_set_resend_when_in_progress(irq_get_irq_data(virq + i));
}
- if (err) {
- if (i > 0)
- its_vpe_irq_domain_free(domain, virq, i);
-
- its_lpi_free(bitmap, base, nr_ids);
- its_free_prop_table(vprop_page);
- }
+ if (err)
+ its_vpe_irq_domain_free(domain, virq, i);
return err;
}
--
2.36.1
Powered by blists - more mailing lists