提交 0fd7d43f 编写于 作者: W Wei Yongjun 提交者: David S. Miller

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: 54e19bc7 ("net: qcom/emac: do not use devm on internal
phy pdev")
Signed-off-by: NWei Yongjun <weiyongjun1@huawei.com>
Acked-by: NTimur Tabi <timur@codeaurora.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 b6a79208
......@@ -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;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册