Skip to content

Commit

Permalink
net: ll_temac: Use devm_platform_ioremap_resource_byname()
Browse files Browse the repository at this point in the history
platform_get_resource() may fail and return NULL, so we had better
check its return value to avoid a NULL pointer dereference a bit later
in the code. Fix it to use devm_platform_ioremap_resource_byname()
instead of calling platform_get_resource_byname() and devm_ioremap().

Fixes: 8425c41 ("net: ll_temac: Extend support to non-device-tree platforms")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Wang Hai authored and davem330 committed Jul 31, 2020
1 parent 3ce38d3 commit bd69058
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions drivers/net/ethernet/xilinx/ll_temac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1407,10 +1407,8 @@ static int temac_probe(struct platform_device *pdev)
}

/* map device registers */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
lp->regs = devm_ioremap(&pdev->dev, res->start,
resource_size(res));
if (!lp->regs) {
lp->regs = devm_platform_ioremap_resource_byname(pdev, 0);
if (IS_ERR(lp->regs)) {
dev_err(&pdev->dev, "could not map TEMAC registers\n");
return -ENOMEM;
}
Expand Down

0 comments on commit bd69058

Please sign in to comment.