All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Tianyi Jing <jingfelix@hust.edu.cn>
Cc: Jean Delvare <jdelvare@suse.com>,
	Dongliang Mu <dzm91@hust.edu.cn>,
	linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] drivers: hwmon: fix ioremap and memremap leak
Date: Tue, 21 Mar 2023 07:52:51 -0700	[thread overview]
Message-ID: <668f31bc-79af-4100-997e-089ed359985a@roeck-us.net> (raw)
In-Reply-To: <20230318143851.2191625-1-jingfelix@hust.edu.cn>

On Sat, Mar 18, 2023 at 10:38:51PM +0800, Tianyi Jing wrote:
> Smatch reports:
> 
> drivers/hwmon/xgene-hwmon.c:757 xgene_hwmon_probe() warn:
> 'ctx->pcc_comm_addr' from ioremap() not released on line: 757.
> 
> This is because in drivers/hwmon/xgene-hwmon.c:701 xgene_hwmon_probe(),
> ioremap and memremap is not released, which may cause a leak.
> 
> To fix this, ioremap and memremap is modified to devm_ioremap and
> devm_memremap.
> 
> Signed-off-by: Tianyi Jing <jingfelix@hust.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>

Applied. Note that I updated the subject and changed formatting a bit.

Guenter

> ---
> v1 -> v2: use devm_ioremap and devm_memremap instead.
>  drivers/hwmon/xgene-hwmon.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hwmon/xgene-hwmon.c b/drivers/hwmon/xgene-hwmon.c
> index 5cde837bfd09..a25fae9b19b7 100644
> --- a/drivers/hwmon/xgene-hwmon.c
> +++ b/drivers/hwmon/xgene-hwmon.c
> @@ -698,11 +698,13 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
>  		ctx->comm_base_addr = pcc_chan->shmem_base_addr;
>  		if (ctx->comm_base_addr) {
>  			if (version == XGENE_HWMON_V2)
> -				ctx->pcc_comm_addr = (void __force *)ioremap(
> +				ctx->pcc_comm_addr = (void __force *)devm_ioremap(
> +							&pdev->dev,
>  							ctx->comm_base_addr,
>  							pcc_chan->shmem_size);
>  			else
> -				ctx->pcc_comm_addr = memremap(
> +				ctx->pcc_comm_addr = devm_memremap(
> +							&pdev->dev,
>  							ctx->comm_base_addr,
>  							pcc_chan->shmem_size,
>  							MEMREMAP_WB);

      reply	other threads:[~2023-03-21 14:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-18 14:38 [PATCH v2] drivers: hwmon: fix ioremap and memremap leak Tianyi Jing
2023-03-21 14:52 ` Guenter Roeck [this message]

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=668f31bc-79af-4100-997e-089ed359985a@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=dzm91@hust.edu.cn \
    --cc=jdelvare@suse.com \
    --cc=jingfelix@hust.edu.cn \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.