[OpenWrt-Devel] ag71xx: fix return value check in ag71xx_probe()
diff mbox series

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()
Related show

Commit Message

Rosen Penev Feb. 7, 2020, 3:31 a.m. UTC
From: Wei Yongjun <weiyongjun1@huawei.com>

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().

Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
 target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Petr Štetiar Feb. 11, 2020, 10:36 a.m. UTC | #1
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

Patch
diff mbox series

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);
 	}