Skip to content

Commit 0fd7d43

Browse files
Wei Yongjundavem330
authored andcommitted
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: 54e19bc ("net: qcom/emac: do not use devm on internal phy pdev") Signed-off-by: Wei Yongjun <[email protected]> Acked-by: Timur Tabi <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b6a7920 commit 0fd7d43

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

drivers/net/ethernet/qualcomm/emac/emac-sgmii.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,18 +740,23 @@ int emac_sgmii_config(struct platform_device *pdev, struct emac_adapter *adpt)
740740

741741
/* Base address is the first address */
742742
res = platform_get_resource(sgmii_pdev, IORESOURCE_MEM, 0);
743+
if (!res) {
744+
ret = -EINVAL;
745+
goto error_put_device;
746+
}
747+
743748
phy->base = ioremap(res->start, resource_size(res));
744-
if (IS_ERR(phy->base)) {
745-
ret = PTR_ERR(phy->base);
749+
if (!phy->base) {
750+
ret = -ENOMEM;
746751
goto error_put_device;
747752
}
748753

749754
/* v2 SGMII has a per-lane digital digital, so parse it if it exists */
750755
res = platform_get_resource(sgmii_pdev, IORESOURCE_MEM, 1);
751756
if (res) {
752757
phy->digital = ioremap(res->start, resource_size(res));
753-
if (IS_ERR(phy->digital)) {
754-
ret = PTR_ERR(phy->digital);
758+
if (!phy->digital) {
759+
ret = -ENOMEM;
755760
goto error_unmap_base;
756761
}
757762
}

0 commit comments

Comments
 (0)