* [PATCH] irqchip/riscv-intc: Fix memory leak when riscv_intc_init_common() fails
@ 2024-05-27 8:11 Sunil V L
2024-05-27 8:26 ` Anup Patel
2024-06-03 10:36 ` [tip: irq/urgent] irqchip/riscv-intc: Prevent " tip-bot2 for Sunil V L
0 siblings, 2 replies; 3+ messages in thread
From: Sunil V L @ 2024-05-27 8:11 UTC (permalink / raw)
To: linux-riscv, linux-kernel
Cc: Anup Patel, Thomas Gleixner, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Andrew Jones, Conor Dooley, 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 <sunilvl@ventanamicro.com>
---
drivers/irqchip/irq-riscv-intc.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c
index 9e71c4428814..4f3a12383a1e 100644
--- a/drivers/irqchip/irq-riscv-intc.c
+++ b/drivers/irqchip/irq-riscv-intc.c
@@ -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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] irqchip/riscv-intc: Fix memory leak when riscv_intc_init_common() fails
2024-05-27 8:11 [PATCH] irqchip/riscv-intc: Fix memory leak when riscv_intc_init_common() fails Sunil V L
@ 2024-05-27 8:26 ` Anup Patel
2024-06-03 10:36 ` [tip: irq/urgent] irqchip/riscv-intc: Prevent " tip-bot2 for Sunil V L
1 sibling, 0 replies; 3+ messages in thread
From: Anup Patel @ 2024-05-27 8:26 UTC (permalink / raw)
To: Sunil V L
Cc: linux-riscv, linux-kernel, Thomas Gleixner, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Andrew Jones, Conor Dooley
On Mon, May 27, 2024 at 1:41 PM Sunil V L <sunilvl@ventanamicro.com> wrote:
>
> 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 <sunilvl@ventanamicro.com>
LGTM.
Reviewed-by: Anup Patel <anup@brainfault.org>
Regards,
Anup
> ---
> drivers/irqchip/irq-riscv-intc.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c
> index 9e71c4428814..4f3a12383a1e 100644
> --- a/drivers/irqchip/irq-riscv-intc.c
> +++ b/drivers/irqchip/irq-riscv-intc.c
> @@ -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
>
^ permalink raw reply [flat|nested] 3+ messages in thread* [tip: irq/urgent] irqchip/riscv-intc: Prevent memory leak when riscv_intc_init_common() fails
2024-05-27 8:11 [PATCH] irqchip/riscv-intc: Fix memory leak when riscv_intc_init_common() fails Sunil V L
2024-05-27 8:26 ` Anup Patel
@ 2024-06-03 10:36 ` tip-bot2 for Sunil V L
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Sunil V L @ 2024-06-03 10:36 UTC (permalink / raw)
To: linux-tip-commits
Cc: Sunil V L, Thomas Gleixner, Anup Patel, stable, x86, linux-kernel,
maz
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 <sunilvl@ventanamicro.com>
AuthorDate: Mon, 27 May 2024 13:41:13 +05:30
Committer: Thomas Gleixner <tglx@linutronix.de>
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 <sunilvl@ventanamicro.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Anup Patel <anup@brainfault.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20240527081113.616189-1-sunilvl@ventanamicro.com
---
drivers/irqchip/irq-riscv-intc.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c
index 9e71c44..4f3a123 100644
--- a/drivers/irqchip/irq-riscv-intc.c
+++ b/drivers/irqchip/irq-riscv-intc.c
@@ -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,
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-03 10:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-27 8:11 [PATCH] irqchip/riscv-intc: Fix memory leak when riscv_intc_init_common() fails Sunil V L
2024-05-27 8:26 ` Anup Patel
2024-06-03 10:36 ` [tip: irq/urgent] irqchip/riscv-intc: Prevent " tip-bot2 for Sunil V L
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox