mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzk@kernel.org>
To: Zhen Ni <zhen.ni@easystack.cn>, alim.akhtar@samsung.com
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org
Subject: Re: [PATCH] memory: samsung: exynos-srom: Fix of_iomap leak in exynos_srom_probe
Date: Thu, 31 Jul 2025 11:06:09 +0200	[thread overview]
Message-ID: <aa6ad382-dc2a-4f63-be11-7d331027af66@kernel.org> (raw)
In-Reply-To: <20250731083340.1057564-1-zhen.ni@easystack.cn>

On 31/07/2025 10:33, Zhen Ni wrote:
> The current error handling in exynos_srom_probe() has a resource leak
> in the of_platform_populate() failure path. When this function fails
> after successful resource allocation, srom->reg_base is not released.
> 
> To fix this issue, replace of_iomap() with
> devm_platform_ioremap_resource(). devm_platform_ioremap_resource()
> is a specialized function for platform devices.

Don't explain us kernel code. Drop sentence.

> It allows 'srom->reg_base' to be automatically released whether the
> probe function succeeds or fails.

It's obvious.

> 
> Besides, use IS_ERR() instead of !srom->reg_base

I don't understand this. You keep explaining the code and this suggests
you made change here not related to original case. Can you return
srom->reg_base here? No?


> as the return value of devm_platform_ioremap_resource()
> can either be a pointer to the remapped memory or
> an ERR_PTR() encoded error code if the operation fails.
> 

Missing fixes and cc-stable.

> Signed-off-by: Zhen Ni <zhen.ni@easystack.cn>
> ---
>  drivers/memory/samsung/exynos-srom.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/memory/samsung/exynos-srom.c b/drivers/memory/samsung/exynos-srom.c
> index e73dd330af47..d913fb901973 100644
> --- a/drivers/memory/samsung/exynos-srom.c
> +++ b/drivers/memory/samsung/exynos-srom.c
> @@ -121,20 +121,18 @@ static int exynos_srom_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  
>  	srom->dev = dev;
> -	srom->reg_base = of_iomap(np, 0);
> -	if (!srom->reg_base) {
> +	srom->reg_base = devm_platform_ioremap_resource(pdev, 0);
> +	if (IS_ERR(srom->reg_base)) {
>  		dev_err(&pdev->dev, "iomap of exynos srom controller failed\n");
> -		return -ENOMEM;
> +		return PTR_ERR(srom->reg_base);

How did you test it?

Best regards,
Krzysztof

  reply	other threads:[~2025-07-31  9:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-31  8:33 Zhen Ni
2025-07-31  9:06 ` Krzysztof Kozlowski [this message]
2025-07-31  9:40   ` zhen.ni
2025-07-31 10:59     ` Krzysztof Kozlowski
2025-08-06  2:55 ` [PATCH v2] " Zhen Ni
2025-08-13 10:30   ` Krzysztof Kozlowski

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=aa6ad382-dc2a-4f63-be11-7d331027af66@kernel.org \
    --to=krzk@kernel.org \
    --cc=alim.akhtar@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=zhen.ni@easystack.cn \
    /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

all inboxes | Powered by JetHome®