]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
irqchip/irq-riscv-imsic-early: Fix fwnode leak on state setup failure
authorHaoxiang Li <haoxiang_li2024@163.com>
Tue, 23 Jun 2026 07:37:44 +0000 (15:37 +0800)
committerThomas Gleixner <tglx@kernel.org>
Tue, 30 Jun 2026 16:49:48 +0000 (18:49 +0200)
imsic_early_acpi_init() allocates a firmware node before setting up the
IMSIC state. If imsic_setup_state() fails, the function returns without
freeing the allocated fwnode.

Free the fwnode and clear the global pointer on this error path, matching
the cleanup already done when imsic_early_probe() fails.

[ tglx: Use a common cleanup path instead of copying code around ]

Fixes: fbe826b1c106 ("irqchip/riscv-imsic: Add ACPI support")
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260623073744.2009137-1-haoxiang_li2024@163.com
drivers/irqchip/irq-riscv-imsic-early.c

index a7a1852b548c4854f7746bdd07c6212d8f0ed552..12efd241ce8800c73d74eda8d02a566a595e9e10 100644 (file)
@@ -272,16 +272,13 @@ static int __init imsic_early_acpi_init(union acpi_subtable_headers *header,
        rc = imsic_setup_state(imsic_acpi_fwnode, imsic);
        if (rc) {
                pr_err("%pfwP: failed to setup state (error %d)\n", imsic_acpi_fwnode, rc);
-               return rc;
+               goto cleanup;
        }
 
        /* Do early setup of IMSIC state and IPIs */
        rc = imsic_early_probe(imsic_acpi_fwnode);
-       if (rc) {
-               irq_domain_free_fwnode(imsic_acpi_fwnode);
-               imsic_acpi_fwnode = NULL;
-               return rc;
-       }
+       if (rc)
+               goto cleanup;
 
        rc = imsic_platform_acpi_probe(imsic_acpi_fwnode);
 
@@ -300,8 +297,12 @@ static int __init imsic_early_acpi_init(union acpi_subtable_headers *header,
         * DT where IPI works but MSI probe fails for some reason.
         */
        return 0;
-}
 
+cleanup:
+       irq_domain_free_fwnode(imsic_acpi_fwnode);
+       imsic_acpi_fwnode = NULL;
+       return rc;
+}
 IRQCHIP_ACPI_DECLARE(riscv_imsic, ACPI_MADT_TYPE_IMSIC, NULL,
                     1, imsic_early_acpi_init);
 #endif