]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: ftgmac100: use bus name in mdio error messages
authorZev Weiss <zev@bewilderbeest.net>
Tue, 17 May 2022 22:16:39 +0000 (15:16 -0700)
committerTom Rini <trini@konsulko.com>
Mon, 8 Aug 2022 14:50:20 +0000 (10:50 -0400)
Previously we'd been using a device name retrieved via
ftgmac100_data->phydev, but the mdio read/write functions may be
called before that member is initialized in ftgmac100_phy_init(),
leading to a NULL pointer dereference while printing the error message
issued if the mdio access fails.  We can instead use bus->name, which
is already available at that point.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Fixes: 538e75d3fc54 ("net: ftgmac100: add MDIO bus and phylib support")
Reviewed-by: Cédric Le Goater <clg@kaod.org>
drivers/net/ftgmac100.c

index 78779d7d60b916b9b01059420b06c8c0297ad6bd..74261d14e548ede95f5e65a3722fe64f1659dc5c 100644 (file)
@@ -119,7 +119,7 @@ static int ftgmac100_mdio_read(struct mii_dev *bus, int phy_addr, int dev_addr,
                                 FTGMAC100_MDIO_TIMEOUT_USEC);
        if (ret) {
                pr_err("%s: mdio read failed (phy:%d reg:%x)\n",
-                      priv->phydev->dev->name, phy_addr, reg_addr);
+                      bus->name, phy_addr, reg_addr);
                return ret;
        }
 
@@ -151,7 +151,7 @@ static int ftgmac100_mdio_write(struct mii_dev *bus, int phy_addr, int dev_addr,
                                 FTGMAC100_MDIO_TIMEOUT_USEC);
        if (ret) {
                pr_err("%s: mdio write failed (phy:%d reg:%x)\n",
-                      priv->phydev->dev->name, phy_addr, reg_addr);
+                      bus->name, phy_addr, reg_addr);
        }
 
        return ret;