From: Marc Zyngier <maz@kernel.org>
To: Guanrui Huang <guanrui.huang@linux.alibaba.com>
Cc: yuzenghui@huawei.com, shannon.zhao@linux.alibaba.com,
tglx@linutronix.de, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/2] irqchip/gic-v3-its: Fix double free on error
Date: Sat, 13 Apr 2024 09:44:42 +0100 [thread overview]
Message-ID: <877ch1slc5.wl-maz@kernel.org> (raw)
In-Reply-To: <20240413064051.31315-1-guanrui.huang@linux.alibaba.com>
On Sat, 13 Apr 2024 07:40:50 +0100,
Guanrui Huang <guanrui.huang@linux.alibaba.com> wrote:
>
> 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.
>
> 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;
> }
Reviewed-by: Marc Zyngier <maz@kernel.org>
M.
--
Without deviation from the norm, progress is not possible.
prev parent reply other threads:[~2024-04-13 8:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-13 6:40 [PATCH v4 1/2] irqchip/gic-v3-its: Fix double free on error Guanrui Huang
2024-04-13 6:40 ` [PATCH v4 2/2] irqchip/gic-v3-its: remove BUG_ON in its_vpe_irq_domain_alloc Guanrui Huang
2024-04-13 8:44 ` Marc Zyngier
2024-04-13 8:44 ` Marc Zyngier [this message]
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=877ch1slc5.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=guanrui.huang@linux.alibaba.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox