ramips: 5.4: handle ERR_PTR properly
authorSungbo Eo <mans0n@gorani.run>
Sat, 25 Apr 2020 08:35:53 +0000 (17:35 +0900)
committerChuanhong Guo <gch981213@gmail.com>
Tue, 19 May 2020 11:03:07 +0000 (19:03 +0800)
of_get_mac_address can return ERR_PTR since 5.2, so the return pointer should be
checked before used. Otherwise it might cause an oops during boot.

Signed-off-by: Sungbo Eo <mans0n@gorani.run>
target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.c

index 7191a7a382bfc4f0a8f4e2b52175a2e92363bd9c..358a8fc16dcc214f39038ec26059000cea994a0b 100644 (file)
@@ -1401,7 +1401,7 @@ static int __init fe_init(struct net_device *dev)
        fe_reset_phy(priv);
 
        mac_addr = of_get_mac_address(priv->dev->of_node);
        fe_reset_phy(priv);
 
        mac_addr = of_get_mac_address(priv->dev->of_node);
-       if (mac_addr)
+       if (!IS_ERR_OR_NULL(mac_addr))
                ether_addr_copy(dev->dev_addr, mac_addr);
 
        /* If the mac address is invalid, use random mac address  */
                ether_addr_copy(dev->dev_addr, mac_addr);
 
        /* If the mac address is invalid, use random mac address  */