From: Guanrui Huang <guanrui.huang@linux.alibaba.com> To: maz@kernel.org Cc: Markus.Elfring@web.de, yuzenghui@huawei.com, shannon.zhao@linux.alibaba.com, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Guanrui Huang <guanrui.huang@linux.alibaba.com> Subject: [PATCH v5 1/2] irqchip/gic-v3-its: Fix double free on error Date: Thu, 18 Apr 2024 14:10:52 +0800 [thread overview] Message-ID: <20240418061053.96803-2-guanrui.huang@linux.alibaba.com> (raw) In-Reply-To: <20240418061053.96803-1-guanrui.huang@linux.alibaba.com> 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. Fixes: 7d75bbb4bc1a ("irqchip/gic-v3-its: Add VPE irq domain allocation/teardown") Reviewed-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Zenghui Yu <yuzenghui@huawei.com> Signed-off-by: Guanrui Huang <guanrui.huang@linux.alibaba.com> --- drivers/irqchip/irq-gic-v3-its.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index fca888b36680..2305f6b524a9 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -4561,13 +4561,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
WARNING: multiple messages have this Message-ID (diff)
From: Guanrui Huang <guanrui.huang@linux.alibaba.com> To: maz@kernel.org Cc: Markus.Elfring@web.de, yuzenghui@huawei.com, shannon.zhao@linux.alibaba.com, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Guanrui Huang <guanrui.huang@linux.alibaba.com> Subject: [PATCH v5 1/2] irqchip/gic-v3-its: Fix double free on error Date: Thu, 18 Apr 2024 14:10:52 +0800 [thread overview] Message-ID: <20240418061053.96803-2-guanrui.huang@linux.alibaba.com> (raw) In-Reply-To: <20240418061053.96803-1-guanrui.huang@linux.alibaba.com> 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. Fixes: 7d75bbb4bc1a ("irqchip/gic-v3-its: Add VPE irq domain allocation/teardown") Reviewed-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Zenghui Yu <yuzenghui@huawei.com> Signed-off-by: Guanrui Huang <guanrui.huang@linux.alibaba.com> --- drivers/irqchip/irq-gic-v3-its.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index fca888b36680..2305f6b524a9 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -4561,13 +4561,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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-04-18 6:11 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-04-18 6:10 [PATCH v5 0/2] irqchip/gic-v3-its: Fix double free on error Guanrui Huang 2024-04-18 6:10 ` Guanrui Huang 2024-04-18 6:10 ` Guanrui Huang [this message] 2024-04-18 6:10 ` [PATCH v5 1/2] " Guanrui Huang 2024-04-18 7:55 ` Markus Elfring 2024-04-18 7:55 ` Markus Elfring 2024-04-25 12:46 ` [tip: irq/urgent] irqchip/gic-v3-its: Prevent " tip-bot2 for Guanrui Huang 2024-04-18 6:10 ` [PATCH v5 2/2] irqchip/gic-v3-its: remove BUG_ON in its_vpe_irq_domain_alloc Guanrui Huang 2024-04-18 6:10 ` Guanrui Huang 2024-04-18 6:56 ` Zenghui Yu 2024-04-18 6:56 ` Zenghui Yu 2024-04-25 12:46 ` [tip: irq/core] irqchip/gic-v3-its: Remove " tip-bot2 for Guanrui Huang 2024-04-18 7:18 ` [PATCH v5 0/2] irqchip/gic-v3-its: Fix double free on error Marc Zyngier 2024-04-18 7:18 ` Marc Zyngier
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240418061053.96803-2-guanrui.huang@linux.alibaba.com \ --to=guanrui.huang@linux.alibaba.com \ --cc=Markus.Elfring@web.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=maz@kernel.org \ --cc=shannon.zhao@linux.alibaba.com \ --cc=tglx@linutronix.de \ --cc=yuzenghui@huawei.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.