Skip to content

Commit 1358126

Browse files
Haoxiang LiThomas Gleixner
authored andcommitted
irqchip/irq-riscv-imsic-early: Fix fwnode leak on state setup failure
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: fbe826b ("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
1 parent dc59e4f commit 1358126

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

drivers/irqchip/irq-riscv-imsic-early.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,13 @@ static int __init imsic_early_acpi_init(union acpi_subtable_headers *header,
272272
rc = imsic_setup_state(imsic_acpi_fwnode, imsic);
273273
if (rc) {
274274
pr_err("%pfwP: failed to setup state (error %d)\n", imsic_acpi_fwnode, rc);
275-
return rc;
275+
goto cleanup;
276276
}
277277

278278
/* Do early setup of IMSIC state and IPIs */
279279
rc = imsic_early_probe(imsic_acpi_fwnode);
280-
if (rc) {
281-
irq_domain_free_fwnode(imsic_acpi_fwnode);
282-
imsic_acpi_fwnode = NULL;
283-
return rc;
284-
}
280+
if (rc)
281+
goto cleanup;
285282

286283
rc = imsic_platform_acpi_probe(imsic_acpi_fwnode);
287284

@@ -300,8 +297,12 @@ static int __init imsic_early_acpi_init(union acpi_subtable_headers *header,
300297
* DT where IPI works but MSI probe fails for some reason.
301298
*/
302299
return 0;
303-
}
304300

301+
cleanup:
302+
irq_domain_free_fwnode(imsic_acpi_fwnode);
303+
imsic_acpi_fwnode = NULL;
304+
return rc;
305+
}
305306
IRQCHIP_ACPI_DECLARE(riscv_imsic, ACPI_MADT_TYPE_IMSIC, NULL,
306307
1, imsic_early_acpi_init);
307308
#endif

0 commit comments

Comments
 (0)