public inbox for linux-edac@vger.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: Miaoqian Lin <linmq006@gmail.com>
Cc: Borislav Petkov <bp@alien8.de>, Tony Luck <tony.luck@intel.com>,
	James Morse <james.morse@arm.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Robert Richter <rric@kernel.org>,
	Rob Herring <rob.herring@calxeda.com>,
	linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] EDAC: highbank: Fix memory leak in highbank_mc_probe
Date: Tue, 3 Jan 2023 12:25:41 +0000	[thread overview]
Message-ID: <20230103122541.5e5cf0dc@donnerap.cambridge.arm.com> (raw)
In-Reply-To: <20221229054825.1361993-1-linmq006@gmail.com>

On Thu, 29 Dec 2022 09:48:24 +0400
Miaoqian Lin <linmq006@gmail.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@arm.com>

Cheers,
Andre

> Fixes: a1b01edb2745 ("edac: add support for Calxeda highbank memory controller")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.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;
>  }


  reply	other threads:[~2023-01-03 12:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-29  5:48 [PATCH] EDAC: highbank: Fix memory leak in highbank_mc_probe Miaoqian Lin
2023-01-03 12:25 ` Andre Przywara [this message]
2023-01-03 16:41 ` Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230103122541.5e5cf0dc@donnerap.cambridge.arm.com \
    --to=andre.przywara@arm.com \
    --cc=bp@alien8.de \
    --cc=james.morse@arm.com \
    --cc=linmq006@gmail.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=rob.herring@calxeda.com \
    --cc=rric@kernel.org \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox