All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drivers: loongson: fix memory leak in loongson2_guts_probe
@ 2023-03-06  2:53 Dongliang Mu
  2023-03-06  3:01 ` Huacai Chen
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Dongliang Mu @ 2023-03-06  2:53 UTC (permalink / raw)
  To: Yinbo Zhu; +Cc: Dongliang Mu, loongarch, linux-kernel

drivers/soc/loongson/loongson2_guts.c:150 loongson2_guts_probe()
warn: 'guts->regs' from ioremap() not released on lines: 131,135,139,143.

Fix this by modifying ioremap to devm_ioremap.

Note that, this patch is not tested due to the loongson architecture.

Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>
---
v1->v2: instead of modifying error handling code, directly change
ioremap to devm_ioremap.
 drivers/soc/loongson/loongson2_guts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/loongson/loongson2_guts.c b/drivers/soc/loongson/loongson2_guts.c
index bace4bc8e03b..a053e3fdae09 100644
--- a/drivers/soc/loongson/loongson2_guts.c
+++ b/drivers/soc/loongson/loongson2_guts.c
@@ -107,7 +107,7 @@ static int loongson2_guts_probe(struct platform_device *pdev)
 	guts->little_endian = of_property_read_bool(np, "little-endian");
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	guts->regs = ioremap(res->start, res->end - res->start + 1);
+	guts->regs = devm_ioremap(dev, res->start, res->end - res->start + 1);
 	if (IS_ERR(guts->regs))
 		return PTR_ERR(guts->regs);
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] drivers: loongson: fix memory leak in loongson2_guts_probe
  2023-03-06  2:53 [PATCH v2] drivers: loongson: fix memory leak in loongson2_guts_probe Dongliang Mu
@ 2023-03-06  3:01 ` Huacai Chen
  2023-03-06  3:03 ` WANG Xuerui
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Huacai Chen @ 2023-03-06  3:01 UTC (permalink / raw)
  To: Dongliang Mu; +Cc: Yinbo Zhu, loongarch, linux-kernel

Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>

On Mon, Mar 6, 2023 at 10:55 AM Dongliang Mu <dzm91@hust.edu.cn> wrote:
>
> drivers/soc/loongson/loongson2_guts.c:150 loongson2_guts_probe()
> warn: 'guts->regs' from ioremap() not released on lines: 131,135,139,143.
>
> Fix this by modifying ioremap to devm_ioremap.
>
> Note that, this patch is not tested due to the loongson architecture.
>
> Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>
> ---
> v1->v2: instead of modifying error handling code, directly change
> ioremap to devm_ioremap.
>  drivers/soc/loongson/loongson2_guts.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/soc/loongson/loongson2_guts.c b/drivers/soc/loongson/loongson2_guts.c
> index bace4bc8e03b..a053e3fdae09 100644
> --- a/drivers/soc/loongson/loongson2_guts.c
> +++ b/drivers/soc/loongson/loongson2_guts.c
> @@ -107,7 +107,7 @@ static int loongson2_guts_probe(struct platform_device *pdev)
>         guts->little_endian = of_property_read_bool(np, "little-endian");
>
>         res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -       guts->regs = ioremap(res->start, res->end - res->start + 1);
> +       guts->regs = devm_ioremap(dev, res->start, res->end - res->start + 1);
>         if (IS_ERR(guts->regs))
>                 return PTR_ERR(guts->regs);
>
> --
> 2.39.2
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] drivers: loongson: fix memory leak in loongson2_guts_probe
  2023-03-06  2:53 [PATCH v2] drivers: loongson: fix memory leak in loongson2_guts_probe Dongliang Mu
  2023-03-06  3:01 ` Huacai Chen
@ 2023-03-06  3:03 ` WANG Xuerui
  2023-03-06  3:20   ` Dongliang Mu
  2023-03-06  3:40 ` zhuyinbo
  2023-08-01  8:15 ` Huacai Chen
  3 siblings, 1 reply; 6+ messages in thread
From: WANG Xuerui @ 2023-03-06  3:03 UTC (permalink / raw)
  To: Dongliang Mu, Yinbo Zhu; +Cc: loongarch, linux-kernel

On 2023/3/6 10:53, Dongliang Mu wrote:
> drivers/soc/loongson/loongson2_guts.c:150 loongson2_guts_probe()
> warn: 'guts->regs' from ioremap() not released on lines: 131,135,139,143.
> 
> Fix this by modifying ioremap to devm_ioremap.
> 
> Note that, this patch is not tested due to the loongson architecture.
> 
> Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>
> ---
> v1->v2: instead of modifying error handling code, directly change
> ioremap to devm_ioremap.
>   drivers/soc/loongson/loongson2_guts.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/soc/loongson/loongson2_guts.c b/drivers/soc/loongson/loongson2_guts.c
> index bace4bc8e03b..a053e3fdae09 100644
> --- a/drivers/soc/loongson/loongson2_guts.c
> +++ b/drivers/soc/loongson/loongson2_guts.c
> @@ -107,7 +107,7 @@ static int loongson2_guts_probe(struct platform_device *pdev)
>   	guts->little_endian = of_property_read_bool(np, "little-endian");
>   
>   	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	guts->regs = ioremap(res->start, res->end - res->start + 1);
> +	guts->regs = devm_ioremap(dev, res->start, res->end - res->start + 1);

resource_size(res) is exactly "res->end - res->start + 1", you may use 
that to simplify code now that you touched this line.

>   	if (IS_ERR(guts->regs))
>   		return PTR_ERR(guts->regs);
>   

Otherwise LGTM, thanks! Untested by me though,

Reviewed-by: WANG Xuerui <git@xen0n.name>

-- 
WANG "xen0n" Xuerui

Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] drivers: loongson: fix memory leak in loongson2_guts_probe
  2023-03-06  3:03 ` WANG Xuerui
@ 2023-03-06  3:20   ` Dongliang Mu
  0 siblings, 0 replies; 6+ messages in thread
From: Dongliang Mu @ 2023-03-06  3:20 UTC (permalink / raw)
  To: WANG Xuerui; +Cc: Yinbo Zhu, loongarch, linux-kernel


> On Mar 6, 2023, at 11:03, WANG Xuerui <kernel@xen0n.name> wrote:
> 
> On 2023/3/6 10:53, Dongliang Mu wrote:
>> drivers/soc/loongson/loongson2_guts.c:150 loongson2_guts_probe()
>> warn: 'guts->regs' from ioremap() not released on lines: 131,135,139,143.
>> Fix this by modifying ioremap to devm_ioremap.
>> Note that, this patch is not tested due to the loongson architecture.
>> Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>
>> ---
>> v1->v2: instead of modifying error handling code, directly change
>> ioremap to devm_ioremap.
>>  drivers/soc/loongson/loongson2_guts.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> diff --git a/drivers/soc/loongson/loongson2_guts.c b/drivers/soc/loongson/loongson2_guts.c
>> index bace4bc8e03b..a053e3fdae09 100644
>> --- a/drivers/soc/loongson/loongson2_guts.c
>> +++ b/drivers/soc/loongson/loongson2_guts.c
>> @@ -107,7 +107,7 @@ static int loongson2_guts_probe(struct platform_device *pdev)
>>  	guts->little_endian = of_property_read_bool(np, "little-endian");
>>    	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> -	guts->regs = ioremap(res->start, res->end - res->start + 1);
>> +	guts->regs = devm_ioremap(dev, res->start, res->end - res->start + 1);
> 
> resource_size(res) is exactly "res->end - res->start + 1", you may use that to simplify code now that you touched this line.

I will send a v3 patch since this is a good suggestion.

> 
>>  	if (IS_ERR(guts->regs))
>>  		return PTR_ERR(guts->regs);
>>  
> 
> Otherwise LGTM, thanks! Untested by me though,
> 
> Reviewed-by: WANG Xuerui <git@xen0n.name>
> 
> -- 
> WANG "xen0n" Xuerui
> 
> Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] drivers: loongson: fix memory leak in loongson2_guts_probe
  2023-03-06  2:53 [PATCH v2] drivers: loongson: fix memory leak in loongson2_guts_probe Dongliang Mu
  2023-03-06  3:01 ` Huacai Chen
  2023-03-06  3:03 ` WANG Xuerui
@ 2023-03-06  3:40 ` zhuyinbo
  2023-08-01  8:15 ` Huacai Chen
  3 siblings, 0 replies; 6+ messages in thread
From: zhuyinbo @ 2023-03-06  3:40 UTC (permalink / raw)
  To: Dongliang Mu; +Cc: loongarch, linux-kernel

Tested-by: Yinbo Zhu <zhuyinbo@loongson.cn>

在 2023/3/6 上午10:53, Dongliang Mu 写道:
> drivers/soc/loongson/loongson2_guts.c:150 loongson2_guts_probe()
> warn: 'guts->regs' from ioremap() not released on lines: 131,135,139,143.
>
> Fix this by modifying ioremap to devm_ioremap.
>
> Note that, this patch is not tested due to the loongson architecture.
>
> Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>
> ---
> v1->v2: instead of modifying error handling code, directly change
> ioremap to devm_ioremap.
>   drivers/soc/loongson/loongson2_guts.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/soc/loongson/loongson2_guts.c b/drivers/soc/loongson/loongson2_guts.c
> index bace4bc8e03b..a053e3fdae09 100644
> --- a/drivers/soc/loongson/loongson2_guts.c
> +++ b/drivers/soc/loongson/loongson2_guts.c
> @@ -107,7 +107,7 @@ static int loongson2_guts_probe(struct platform_device *pdev)
>   	guts->little_endian = of_property_read_bool(np, "little-endian");
>   
>   	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -	guts->regs = ioremap(res->start, res->end - res->start + 1);
> +	guts->regs = devm_ioremap(dev, res->start, res->end - res->start + 1);
>   	if (IS_ERR(guts->regs))
>   		return PTR_ERR(guts->regs);
>   


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] drivers: loongson: fix memory leak in loongson2_guts_probe
  2023-03-06  2:53 [PATCH v2] drivers: loongson: fix memory leak in loongson2_guts_probe Dongliang Mu
                   ` (2 preceding siblings ...)
  2023-03-06  3:40 ` zhuyinbo
@ 2023-08-01  8:15 ` Huacai Chen
  3 siblings, 0 replies; 6+ messages in thread
From: Huacai Chen @ 2023-08-01  8:15 UTC (permalink / raw)
  To: Dongliang Mu; +Cc: Yinbo Zhu, loongarch, linux-kernel

Hi, Dongliang,

Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
And please resend this patch with title "soc: loongson: fix memory
leak in loongson2_guts_probe()", cc Arnd and soc@kernel.org, because
that is the most appropriate list for this patch.

Huacai

On Mon, Mar 6, 2023 at 10:55 AM Dongliang Mu <dzm91@hust.edu.cn> wrote:
>
> drivers/soc/loongson/loongson2_guts.c:150 loongson2_guts_probe()
> warn: 'guts->regs' from ioremap() not released on lines: 131,135,139,143.
>
> Fix this by modifying ioremap to devm_ioremap.
>
> Note that, this patch is not tested due to the loongson architecture.
>
> Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>
> ---
> v1->v2: instead of modifying error handling code, directly change
> ioremap to devm_ioremap.
>  drivers/soc/loongson/loongson2_guts.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/soc/loongson/loongson2_guts.c b/drivers/soc/loongson/loongson2_guts.c
> index bace4bc8e03b..a053e3fdae09 100644
> --- a/drivers/soc/loongson/loongson2_guts.c
> +++ b/drivers/soc/loongson/loongson2_guts.c
> @@ -107,7 +107,7 @@ static int loongson2_guts_probe(struct platform_device *pdev)
>         guts->little_endian = of_property_read_bool(np, "little-endian");
>
>         res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> -       guts->regs = ioremap(res->start, res->end - res->start + 1);
> +       guts->regs = devm_ioremap(dev, res->start, res->end - res->start + 1);
>         if (IS_ERR(guts->regs))
>                 return PTR_ERR(guts->regs);
>
> --
> 2.39.2
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-08-01  8:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-06  2:53 [PATCH v2] drivers: loongson: fix memory leak in loongson2_guts_probe Dongliang Mu
2023-03-06  3:01 ` Huacai Chen
2023-03-06  3:03 ` WANG Xuerui
2023-03-06  3:20   ` Dongliang Mu
2023-03-06  3:40 ` zhuyinbo
2023-08-01  8:15 ` Huacai Chen

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.