aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorWei Yongjun2016-10-01 09:12:29 +0000
committerDavid S. Miller2016-10-03 21:53:03 -0400
commit0fd7d43fbc4aaf358005231a6bed27eb1c2f60c3 (patch)
tree85e647d9d49add35a16f454521c217cea7e2a29b /drivers/net/ethernet
parentb6a7920848cab619b5e434fdc0338778c63ef3f3 (diff)
net: qcom/emac: fix return value check in emac_sgmii_config()
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> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/qualcomm/emac/emac-sgmii.c13
1 files 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 3d2c05a40d2c..75c1b530e39e 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;
}
}