* [PATCH net v3] net: macb: fix an issue about leak related system resources
@ 2020-05-03 12:32 Dejin Zheng
2020-05-03 15:02 ` Nicolas.Ferre
2020-05-03 23:02 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Dejin Zheng @ 2020-05-03 12:32 UTC (permalink / raw)
To: nicolas.ferre, davem, paul.walmsley, palmer, yash.shah, netdev
Cc: linux-kernel, Dejin Zheng, Andy Shevchenko
A call of the function macb_init() can fail in the function
fu540_c000_init. The related system resources were not released
then. use devm_platform_ioremap_resource() to replace ioremap()
to fix it.
Fixes: c218ad559020ff9 ("macb: Add support for SiFive FU540-C000")
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Yash Shah <yash.shah@sifive.com>
Suggested-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
---
v2 -> v3:
- use IS_ERR() and PTR_ERR() for error handling by Nicolas's
suggestion. Thanks Nicolas!
v1 -> v2:
- Nicolas and Andy suggest use devm_platform_ioremap_resource()
to repalce devm_ioremap() to fix this issue. Thanks Nicolas
and Andy.
- Yash help me to review this patch, Thanks Yash!
drivers/net/ethernet/cadence/macb_main.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index a0e8c5bbabc0..f040a36d6e54 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4172,15 +4172,9 @@ static int fu540_c000_clk_init(struct platform_device *pdev, struct clk **pclk,
static int fu540_c000_init(struct platform_device *pdev)
{
- struct resource *res;
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- if (!res)
- return -ENODEV;
-
- mgmt->reg = ioremap(res->start, resource_size(res));
- if (!mgmt->reg)
- return -ENOMEM;
+ mgmt->reg = devm_platform_ioremap_resource(pdev, 1);
+ if (IS_ERR(mgmt->reg))
+ return PTR_ERR(mgmt->reg);
return macb_init(pdev);
}
--
2.25.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net v3] net: macb: fix an issue about leak related system resources
2020-05-03 12:32 [PATCH net v3] net: macb: fix an issue about leak related system resources Dejin Zheng
@ 2020-05-03 15:02 ` Nicolas.Ferre
2020-05-03 23:02 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Nicolas.Ferre @ 2020-05-03 15:02 UTC (permalink / raw)
To: zhengdejin5, davem, paul.walmsley, palmer, yash.shah, netdev
Cc: linux-kernel, andy.shevchenko
On 03/05/2020 at 14:32, Dejin Zheng wrote:
> A call of the function macb_init() can fail in the function
> fu540_c000_init. The related system resources were not released
> then. use devm_platform_ioremap_resource() to replace ioremap()
> to fix it.
>
> Fixes: c218ad559020ff9 ("macb: Add support for SiFive FU540-C000")
> Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
> Reviewed-by: Yash Shah <yash.shah@sifive.com>
> Suggested-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
> Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
> ---
> v2 -> v3:
> - use IS_ERR() and PTR_ERR() for error handling by Nicolas's
> suggestion. Thanks Nicolas!
> v1 -> v2:
> - Nicolas and Andy suggest use devm_platform_ioremap_resource()
> to repalce devm_ioremap() to fix this issue. Thanks Nicolas
> and Andy.
> - Yash help me to review this patch, Thanks Yash!
>
> drivers/net/ethernet/cadence/macb_main.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index a0e8c5bbabc0..f040a36d6e54 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -4172,15 +4172,9 @@ static int fu540_c000_clk_init(struct platform_device *pdev, struct clk **pclk,
>
> static int fu540_c000_init(struct platform_device *pdev)
> {
> - struct resource *res;
> -
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> - if (!res)
> - return -ENODEV;
> -
> - mgmt->reg = ioremap(res->start, resource_size(res));
> - if (!mgmt->reg)
> - return -ENOMEM;
> + mgmt->reg = devm_platform_ioremap_resource(pdev, 1);
> + if (IS_ERR(mgmt->reg))
> + return PTR_ERR(mgmt->reg);
>
> return macb_init(pdev);
> }
> --
> 2.25.0
>
--
Nicolas Ferre
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net v3] net: macb: fix an issue about leak related system resources
2020-05-03 12:32 [PATCH net v3] net: macb: fix an issue about leak related system resources Dejin Zheng
2020-05-03 15:02 ` Nicolas.Ferre
@ 2020-05-03 23:02 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-05-03 23:02 UTC (permalink / raw)
To: zhengdejin5
Cc: nicolas.ferre, paul.walmsley, palmer, yash.shah, netdev,
linux-kernel, andy.shevchenko
From: Dejin Zheng <zhengdejin5@gmail.com>
Date: Sun, 3 May 2020 20:32:26 +0800
> A call of the function macb_init() can fail in the function
> fu540_c000_init. The related system resources were not released
> then. use devm_platform_ioremap_resource() to replace ioremap()
> to fix it.
>
> Fixes: c218ad559020ff9 ("macb: Add support for SiFive FU540-C000")
> Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
> Reviewed-by: Yash Shah <yash.shah@sifive.com>
> Suggested-by: Nicolas Ferre <nicolas.ferre@microchip.com>
> Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-03 23:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-03 12:32 [PATCH net v3] net: macb: fix an issue about leak related system resources Dejin Zheng
2020-05-03 15:02 ` Nicolas.Ferre
2020-05-03 23:02 ` David Miller
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.