net: hns: fix warning of passing zero to 'PTR_ERR'
authorKejian Yan <yankejian@huawei.com>
Thu, 24 Mar 2016 11:08:05 +0000 (19:08 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 24 Mar 2016 18:33:07 +0000 (14:33 -0400)
There is a misuse of PTR as shown below:

ae_node = (void *)of_parse_phandle(dev->of_node,
   "ae-handle",
   0);
if (IS_ERR_OR_NULL(ae_node)) {
ret = PTR_ERR(ae_node);
dev_err(dev, "not find ae-handle\n");
goto out_read_prop_fail;
}

if the ae_node is NULL, PTR_ERR(ae_node) means it returns success. And the
return value should be -ENODEV.

Signed-off-by: Kejian Yan <yankejian@huawei.com>
Signed-off-by: Yisen Zhuang <Yisen.Zhuang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns/hns_enet.c

index 66d1652..687204b 100644 (file)
@@ -1814,7 +1814,7 @@ static int hns_nic_try_get_ae(struct net_device *ndev)
        h = hnae_get_handle(&priv->netdev->dev,
                            priv->ae_node, priv->port_id, NULL);
        if (IS_ERR_OR_NULL(h)) {
-               ret = PTR_ERR(h);
+               ret = -ENODEV;
                dev_dbg(priv->dev, "has not handle, register notifier!\n");
                goto out;
        }