[PATCH v5 3/4] irqchip/gic-v3-its: Fix leak in its_vpe_irq_domain_alloc()

Marc Zyngier maz at kernel.org
Mon Jul 20 01:50:00 PDT 2026


On Mon, 20 Jul 2026 08:12:14 +0100,
Kemeng Shi <shikemeng at huaweicloud.com> wrote:
> 
> When its_irq_gic_domain_alloc() fails, the following
> its_vpe_irq_domain_free() skips calling its_vep_teardown() for the
> corresponding irq. Try its_vpe_teardown() in error handling to avoid
> the leak issue.
> 
> Fixes: 7d75bbb4bc1ad ("irqchip/gic-v3-its: Add VPE irq domain allocation/teardown")
> Signed-off-by: Kemeng Shi <shikemeng at huaweicloud.com>
> ---
>  drivers/irqchip/irq-gic-v3-its.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
> index 3e4edcb64065..5dc91862fc15 100644
> --- a/drivers/irqchip/irq-gic-v3-its.c
> +++ b/drivers/irqchip/irq-gic-v3-its.c
> @@ -4594,9 +4594,11 @@ static int its_vpe_init(struct its_vpe *vpe)
>  
>  static void its_vpe_teardown(struct its_vpe *vpe)
>  {
> -	its_vpe_db_proxy_unmap(vpe);
> -	its_vpe_id_free(vpe->vpe_id);
> -	its_free_pending_table(vpe->vpt_page);
> +	if (vpe->vpt_page != NULL) {
> +		its_vpe_db_proxy_unmap(vpe);
> +		its_vpe_id_free(vpe->vpe_id);
> +		its_free_pending_table(vpe->vpt_page);
> +	}

Please keep the diff minimal by doing an early return. This also
deserves a comment, because this is not completely obvious:

diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
index 6f5811aae59c1..38032067135b6 100644
--- a/drivers/irqchip/irq-gic-v3-its.c
+++ b/drivers/irqchip/irq-gic-v3-its.c
@@ -4592,6 +4592,13 @@ static int its_vpe_init(struct its_vpe *vpe)
 
 static void its_vpe_teardown(struct its_vpe *vpe)
 {
+	/*
+	 * If vpt_page is NULL, then its_vpe_init() has failed, and
+	 * there is nothing to do as no resource has been allocated.
+	 */
+	if (!vpe->vpt_page)
+		return;
+
 	its_vpe_db_proxy_unmap(vpe);
 	its_vpe_id_free(vpe->vpe_id);
 	its_free_pending_table(vpe->vpt_page);

	M.

-- 
Without deviation from the norm, progress is not possible.



More information about the linux-arm-kernel mailing list