Skip to content

Commit

Permalink
net: qcom/emac: fix return value check in emac_sgmii_config()
Browse files Browse the repository at this point in the history
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: 54e19bc ("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>
  • Loading branch information
Wei Yongjun authored and David S. Miller committed Oct 4, 2016
1 parent b6a7920 commit 0fd7d43
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,18 +740,23 @@ 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;
}

/* v2 SGMII has a per-lane digital digital, so parse it if it exists */
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;
}
}
Expand Down

0 comments on commit 0fd7d43

Please sign in to comment.