* [PATCH -next] net: qcom/emac: fix return value check in emac_sgmii_config()
@ 2016-10-01 9:12 Wei Yongjun
2016-10-03 19:41 ` Timur Tabi
2016-10-04 1:53 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Wei Yongjun @ 2016-10-01 9:12 UTC (permalink / raw)
To: Timur Tabi; +Cc: Wei Yongjun, netdev
From: Wei Yongjun <weiyongjun1@huawei.com>
In case of error, the function ioremap() returns NULL pointer
not ERR_PTR(). The IS_ERR() test in the return value check
should be replaced with NULL test.
Also add check for return value of platform_get_resource().
Fixes: 54e19bc74f33 ("net: qcom/emac: do not use devm on internal
phy pdev")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
index 3d2c05a..75c1b53 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
@@ -740,9 +740,14 @@ int emac_sgmii_config(struct platform_device *pdev, struct emac_adapter *adpt)
/* Base address is the first address */
res = platform_get_resource(sgmii_pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ ret = -EINVAL;
+ goto error_put_device;
+ }
+
phy->base = ioremap(res->start, resource_size(res));
- if (IS_ERR(phy->base)) {
- ret = PTR_ERR(phy->base);
+ if (!phy->base) {
+ ret = -ENOMEM;
goto error_put_device;
}
@@ -750,8 +755,8 @@ int emac_sgmii_config(struct platform_device *pdev, struct emac_adapter *adpt)
res = platform_get_resource(sgmii_pdev, IORESOURCE_MEM, 1);
if (res) {
phy->digital = ioremap(res->start, resource_size(res));
- if (IS_ERR(phy->digital)) {
- ret = PTR_ERR(phy->digital);
+ if (!phy->digital) {
+ ret = -ENOMEM;
goto error_unmap_base;
}
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH -next] net: qcom/emac: fix return value check in emac_sgmii_config()
2016-10-01 9:12 [PATCH -next] net: qcom/emac: fix return value check in emac_sgmii_config() Wei Yongjun
@ 2016-10-03 19:41 ` Timur Tabi
2016-10-04 1:53 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Timur Tabi @ 2016-10-03 19:41 UTC (permalink / raw)
To: Wei Yongjun; +Cc: Wei Yongjun, netdev
Wei Yongjun wrote:
> From: Wei Yongjun<weiyongjun1@huawei.com>
>
> In case of error, the function ioremap() returns NULL pointer
> not ERR_PTR(). The IS_ERR() test in the return value check
> should be replaced with NULL test.
>
> Also add check for return value of platform_get_resource().
>
> Fixes: 54e19bc74f33 ("net: qcom/emac: do not use devm on internal
> phy pdev")
> Signed-off-by: Wei Yongjun<weiyongjun1@huawei.com>
Acked-by: Timur Tabi <timur@codeaurora.org>
Thanks for this. When I switched from devm_ioremap_resource() to
ioremap(), I didn't think to verify the return values.
--
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc. Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] net: qcom/emac: fix return value check in emac_sgmii_config()
2016-10-01 9:12 [PATCH -next] net: qcom/emac: fix return value check in emac_sgmii_config() Wei Yongjun
2016-10-03 19:41 ` Timur Tabi
@ 2016-10-04 1:53 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-10-04 1:53 UTC (permalink / raw)
To: weiyj.lk; +Cc: timur, weiyongjun1, netdev
From: Wei Yongjun <weiyj.lk@gmail.com>
Date: Sat, 1 Oct 2016 09:12:29 +0000
> From: Wei Yongjun <weiyongjun1@huawei.com>
>
> In case of error, the function ioremap() returns NULL pointer
> not ERR_PTR(). The IS_ERR() test in the return value check
> should be replaced with NULL test.
>
> Also add check for return value of platform_get_resource().
>
> Fixes: 54e19bc74f33 ("net: qcom/emac: do not use devm on internal
> phy pdev")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-10-04 1:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-01 9:12 [PATCH -next] net: qcom/emac: fix return value check in emac_sgmii_config() Wei Yongjun
2016-10-03 19:41 ` Timur Tabi
2016-10-04 1:53 ` 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).