Skip to content

Commit

Permalink
irqchip/riscv-intc: Prevent memory leak when riscv_intc_init_common()…
Browse files Browse the repository at this point in the history
… fails

BugLink: https://bugs.launchpad.net/bugs/2073788

commit 0110c4b upstream.

When riscv_intc_init_common() fails, the firmware node allocated is not
freed. Add the missing free().

Fixes: 7023b9d ("irqchip/riscv-intc: Add ACPI support")
Signed-off-by: Sunil V L <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Anup Patel <[email protected]>
Cc: [email protected]
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Portia Stephens <[email protected]>
Signed-off-by: Roxana Nicolescu <[email protected]>
  • Loading branch information
vlsunil authored and roxanan1996 committed Aug 13, 2024
1 parent 1859390 commit a914d7e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/irqchip/irq-riscv-intc.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ IRQCHIP_DECLARE(riscv, "riscv,cpu-intc", riscv_intc_init);
static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header,
const unsigned long end)
{
struct fwnode_handle *fn;
struct acpi_madt_rintc *rintc;
struct fwnode_handle *fn;
int rc;

rintc = (struct acpi_madt_rintc *)header;

Expand All @@ -196,7 +197,11 @@ static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header,
return -ENOMEM;
}

return riscv_intc_init_common(fn);
rc = riscv_intc_init_common(fn);
if (rc)
irq_domain_free_fwnode(fn);

return rc;
}

IRQCHIP_ACPI_DECLARE(riscv_intc, ACPI_MADT_TYPE_RINTC, NULL,
Expand Down

0 comments on commit a914d7e

Please sign in to comment.