mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-17 17:53:56 +08:00
net: ll_temac: Use devm_platform_ioremap_resource_byname()
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: 8425c41d1e
("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>
This commit is contained in:
parent
3ce38d39ee
commit
bd69058f50
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user