[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230103122541.5e5cf0dc@donnerap.cambridge.arm.com>
Date: Tue, 3 Jan 2023 12:25:41 +0000
From: Andre Przywara <andre.przywara@....com>
To: Miaoqian Lin <linmq006@...il.com>
Cc: Borislav Petkov <bp@...en8.de>, Tony Luck <tony.luck@...el.com>,
James Morse <james.morse@....com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Robert Richter <rric@...nel.org>,
Rob Herring <rob.herring@...xeda.com>,
linux-edac@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] EDAC: highbank: Fix memory leak in highbank_mc_probe
On Thu, 29 Dec 2022 09:48:24 +0400
Miaoqian Lin <linmq006@...il.com> wrote:
Hi,
> edac_mc_alloc() allocates memory. The memory are not released
> when devres_open_group() fails, which causes memory leak.
> Call edac_mc_free() in the error handling to fix this.
Yes, this looks correct.
Reviewed-by: Andre Przywara <andre.przywara@....com>
Cheers,
Andre
> Fixes: a1b01edb2745 ("edac: add support for Calxeda highbank memory controller")
> Signed-off-by: Miaoqian Lin <linmq006@...il.com>
> ---
> altr_sdram_probe() performs similar operations,
> I take it as reference.
> ---
> drivers/edac/highbank_mc_edac.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/edac/highbank_mc_edac.c b/drivers/edac/highbank_mc_edac.c
> index 61b76ec226af..19fba258ae10 100644
> --- a/drivers/edac/highbank_mc_edac.c
> +++ b/drivers/edac/highbank_mc_edac.c
> @@ -174,8 +174,10 @@ static int highbank_mc_probe(struct platform_device *pdev)
> drvdata = mci->pvt_info;
> platform_set_drvdata(pdev, mci);
>
> - if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL))
> - return -ENOMEM;
> + if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) {
> + res = -ENOMEM;
> + goto free;
> + }
>
> r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> if (!r) {
> @@ -243,6 +245,7 @@ static int highbank_mc_probe(struct platform_device *pdev)
> edac_mc_del_mc(&pdev->dev);
> err:
> devres_release_group(&pdev->dev, NULL);
> +free:
> edac_mc_free(mci);
> return res;
> }
Powered by blists - more mailing lists