irqchip/riscv-intc: Fix memory leak when riscv_intc_init_common() fails
Subsystems (4)
PATCH 1/1 irqchip/riscv-intc: Fix memory leak when riscv_intc_init_common() fails
When riscv_intc_init_common() fails, the firmware node allocated is not freed. Fix this memory leak.
Fixes 7023b9d83f03 ("irqchip/riscv-intc: Add ACPI support")
Signed-off-by Sunil V L <[email protected]>
--- drivers/irqchip/irq-riscv-intc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/irqchip/irq-riscv-intc.c +7 -2
@@ -253,8 +253,9 @@ IRQCHIP_DECLARE(andes, "andestech,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;
@@ -273,7 +274,11 @@ static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header,return -ENOMEM ; } -return riscv_intc_init_common (fn, &riscv_intc_chip); + rc =riscv_intc_init_common (fn, &riscv_intc_chip); +if (rc) +irq_domain_free_fwnode (fn); + +return rc; } IRQCHIP_ACPI_DECLARE(riscv_intc, ACPI_MADT_TYPE_RINTC, NULL,
Signature · 1 line
2.40.1
Quoted 6 lines · Sunil V L
When
riscv_intc_init_common()fails, the firmware node allocated is not freed. Fix this memory leak.Fixes 7023b9d83f03 ("irqchip/riscv-intc: Add ACPI support")Signed-off-by Sunil V L <[email protected]>
LGTM.
Reviewed-by Anup Patel <[email protected]>
Regards,
Anup
Quoted 35 lines
--- drivers/irqchip/irq-riscv-intc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/irqchip/irq-riscv-intc.c +7
-3@@ -253,8 +253,9 @@ IRQCHIP_DECLARE(andes, "andestech,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;@@ -273,7 +274,11 @@ static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header,return -ENOMEM ; } -return riscv_intc_init_common (fn, &riscv_intc_chip); + rc =riscv_intc_init_common (fn, &riscv_intc_chip); +if (rc) +irq_domain_free_fwnode (fn); + +return rc; } IRQCHIP_ACPI_DECLARE(riscv_intc, ACPI_MADT_TYPE_RINTC, NULL, --2.40.1
[tip: irq/urgent] irqchip/riscv-intc: Prevent memory leak when riscv_intc_init_common() fails
In reply to Sunil V LThe following commit has been merged into the irq/urgent branch of tip:
The following commit has been merged into the irq/urgent branch of tip:
Commit-ID: 0110c4b110477bb1f19b0d02361846be7ab08300 Gitweb: https://git.kernel.org/tip/0110c4b110477bb1f19b0d02361846be7ab08300 Author: Sunil V L <[email protected]> AuthorDate: Mon, 27 May 2024 13:41:13 +05:30 Committer: Thomas Gleixner <[email protected]> CommitterDate: Mon, 03 Jun 2024 12:29:35 +02:00
irqchip/riscv-intc: Prevent memory leak when riscv_intc_init_common() fails
When riscv_intc_init_common() fails, the firmware node allocated is not freed. Add the missing free().
Fixes 7023b9d83f03 ("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]>
--- drivers/irqchip/irq-riscv-intc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/irqchip/irq-riscv-intc.c +7 -2
@@ -253,8 +253,9 @@ IRQCHIP_DECLARE(andes, "andestech,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;
@@ -273,7 +274,11 @@ static int __init riscv_intc_acpi_init(union acpi_subtable_headers *header,return -ENOMEM ; } -return riscv_intc_init_common (fn, &riscv_intc_chip); + rc =riscv_intc_init_common (fn, &riscv_intc_chip); +if (rc) +irq_domain_free_fwnode (fn); + +return rc; } IRQCHIP_ACPI_DECLARE(riscv_intc, ACPI_MADT_TYPE_RINTC, NULL,