Skip to content

Commit

Permalink
net: macb: fix an issue about leak related system resources
Browse files Browse the repository at this point in the history
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: c218ad5 ("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>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Dejin Zheng authored and David S. Miller committed May 3, 2020
1 parent 57c7f2b commit b959c77
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions drivers/net/ethernet/cadence/macb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4178,15 +4178,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);
}
Expand Down

0 comments on commit b959c77

Please sign in to comment.