[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAhSdy2tDtYPwPPa2o7_JBpVJXynv9+NwRMoOXErjRCcs+xBYg@mail.gmail.com>
Date: Mon, 27 May 2024 13:56:47 +0530
From: Anup Patel <anup@...infault.org>
To: Sunil V L <sunilvl@...tanamicro.com>
Cc: linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org,
Thomas Gleixner <tglx@...utronix.de>, Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>,
Andrew Jones <ajones@...tanamicro.com>, Conor Dooley <conor.dooley@...rochip.com>
Subject: Re: [PATCH] irqchip/riscv-intc: Fix memory leak when
riscv_intc_init_common() fails
On Mon, May 27, 2024 at 1:41 PM Sunil V L <sunilvl@...tanamicro.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@...tanamicro.com>
LGTM.
Reviewed-by: Anup Patel <anup@...infault.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
>
Powered by blists - more mailing lists