net: hns: set correct return value
authorPan Bian <bianpan2016@163.com>
Mon, 30 Oct 2017 08:50:01 +0000 (16:50 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 1 Nov 2017 03:17:44 +0000 (12:17 +0900)
The function of_parse_phandle() returns a NULL pointer if it cannot
resolve a phandle property to a device_node pointer. In function
hns_nic_dev_probe(), its return value is passed to PTR_ERR to extract
the error code. However, in this case, the extracted error code will
always be zero, which is unexpected.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Reviewed-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns/hns_enet.c

index 36520634c96ae127aea4c2994bd6c86ff42e3376..e77192683dbad9a1fca22816e411abf4c3c25d8c 100644 (file)
@@ -2369,8 +2369,8 @@ static int hns_nic_dev_probe(struct platform_device *pdev)
                        priv->enet_ver = AE_VERSION_2;
 
                ae_node = of_parse_phandle(dev->of_node, "ae-handle", 0);
-               if (IS_ERR_OR_NULL(ae_node)) {
-                       ret = PTR_ERR(ae_node);
+               if (!ae_node) {
+                       ret = -ENODEV;
                        dev_err(dev, "not find ae-handle\n");
                        goto out_read_prop_fail;
                }