* [PATCH net] net: ll_temac: Use devm_platform_ioremap_resource_byname()
@ 2020-07-30 7:24 Wang Hai
2020-07-31 0:44 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Wang Hai @ 2020-07-30 7:24 UTC (permalink / raw)
To: davem, kuba, michal.simek, esben, timur, f.fainelli, weiyongjun1,
hkallweit1
Cc: netdev, linux-arm-kernel, linux-kernel
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: 8425c41d1ef7 ("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>
---
drivers/net/ethernet/xilinx/ll_temac_main.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index 929244064abd..9a15f14daa47 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -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;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net: ll_temac: Use devm_platform_ioremap_resource_byname()
2020-07-30 7:24 [PATCH net] net: ll_temac: Use devm_platform_ioremap_resource_byname() Wang Hai
@ 2020-07-31 0:44 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-07-31 0:44 UTC (permalink / raw)
To: wanghai38
Cc: kuba, michal.simek, esben, timur, f.fainelli, weiyongjun1,
hkallweit1, netdev, linux-arm-kernel, linux-kernel
From: Wang Hai <wanghai38@huawei.com>
Date: Thu, 30 Jul 2020 15:24:19 +0800
> 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: 8425c41d1ef7 ("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>
Applied to net-next.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-31 0:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-30 7:24 [PATCH net] net: ll_temac: Use devm_platform_ioremap_resource_byname() Wang Hai
2020-07-31 0:44 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).