Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: hns: set correct return value

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>

authored by

Pan Bian and committed by
David S. Miller
d2083d0e 7db8874a

+2 -2
+2 -2
drivers/net/ethernet/hisilicon/hns/hns_enet.c
··· 2369 2369 priv->enet_ver = AE_VERSION_2; 2370 2370 2371 2371 ae_node = of_parse_phandle(dev->of_node, "ae-handle", 0); 2372 - if (IS_ERR_OR_NULL(ae_node)) { 2373 - ret = PTR_ERR(ae_node); 2372 + if (!ae_node) { 2373 + ret = -ENODEV; 2374 2374 dev_err(dev, "not find ae-handle\n"); 2375 2375 goto out_read_prop_fail; 2376 2376 }