Message ID | 20200207033140.2623-1-rosenp@gmail.com |
---|---|
State | Not Applicable |
Delegated to: | Petr Štetiar |
Headers | show |
Series | [OpenWrt-Devel] ag71xx: fix return value check in ag71xx_probe() | expand |
Rosen Penev <rosenp@gmail.com> [2020-02-06 19:31:40]: Hi, > In case of error, the function of_get_mac_address() returns ERR_PTR() > and never returns NULL. The NULL test in the return value check should > be replaced with IS_ERR(). thanks for your effort, but that is not applicable to 4.19 as the of_get_mac_address returns ERR_PTR since d01f449c008a ("of_net: add NVMEM support to of_get_mac_address"). Seems like 5.4 has already the fix. -- ynezz
diff --git a/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c index 31d27808ddee..8b69d0d7e726 100644 --- a/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c +++ b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c @@ -1581,9 +1581,9 @@ static int ag71xx_probe(struct platform_device *pdev) ag->stop_desc->next = (u32) ag->stop_desc_dma; mac_addr = of_get_mac_address(np); - if (mac_addr) + if (!IS_ERR(mac_addr)) memcpy(dev->dev_addr, mac_addr, ETH_ALEN); - if (!mac_addr || !is_valid_ether_addr(dev->dev_addr)) { + if (IS_ERR(mac_addr) || !is_valid_ether_addr(dev->dev_addr)) { dev_err(&pdev->dev, "invalid MAC address, using random address\n"); eth_random_addr(dev->dev_addr); }