net: macb: fix an issue about leak related system resources
Subsystems (3)
PATCH v3 1/1 net: macb: fix an issue about leak related system resources
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.
---
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(-)
drivers/net/ethernet/cadence/macb_main.c +3 -9
@@ -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); }
Signature · 1 line
2.25.0
Quoted 9 lines · Dejin Zheng
A call of the function
macb_init()can fail in the functionfu540_c000_init. The related system resources were not released then. usedevm_platform_ioremap_resource()to replaceioremap()to fix it.Fixes c218ad559020ff9 ("macb: Add support for SiFive FU540-C000")Cc Andy Shevchenko <[email protected]>Reviewed-by Yash Shah <[email protected]>Suggested-by Nicolas Ferre <[email protected]>
Quoted 41 lines
Suggested-by Andy Shevchenko <[email protected]>Signed-off-by Dejin Zheng <[email protected]>---
v2 -> v3:
- useIS_ERR()andPTR_ERR()for error handling by Nicolas's suggestion. Thanks Nicolas!
v1 -> v2:
- Nicolas and Andy suggest usedevm_platform_ioremap_resource()to repalcedevm_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(-)drivers/net/ethernet/cadence/macb_main.c +3
-10@@ -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
Signature · 1 line
Nicolas Ferre
David Miller
maintainerFrom: Dejin Zheng <[email protected]>
Date: Sun, 3 May 2020 20:32:26 +0800
Quoted 11 lines
A call of the function
macb_init()can fail in the functionfu540_c000_init. The related system resources were not released then. usedevm_platform_ioremap_resource()to replaceioremap()to fix it.Fixes c218ad559020ff9 ("macb: Add support for SiFive FU540-C000")Cc Andy Shevchenko <[email protected]>Reviewed-by Yash Shah <[email protected]>Suggested-by Nicolas Ferre <[email protected]>Suggested-by Andy Shevchenko <[email protected]>Signed-off-by Dejin Zheng <[email protected]>
Applied and queued up for -stable, thanks.