[bug report] net: usb: lan78xx: refactor PHY init to separate detection and MAC configuration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Oleksij Rempel,

Commit d39f339d2603 ("net: usb: lan78xx: refactor PHY init to
separate detection and MAC configuration") from May 5, 2025
(linux-next), leads to the following Smatch static checker warning:

	drivers/net/usb/lan78xx.c:2842 lan78xx_phy_init()
	warn: missing unwind goto?

drivers/net/usb/lan78xx.c
    2805 static int lan78xx_phy_init(struct lan78xx_net *dev)
    2806 {
    2807         __ETHTOOL_DECLARE_LINK_MODE_MASK(fc) = { 0, };
    2808         int ret;
    2809         u32 mii_adv;
    2810         struct phy_device *phydev;
    2811 
    2812         phydev = lan78xx_get_phy(dev);
    2813         if (IS_ERR(phydev))
    2814                 return PTR_ERR(phydev);
    2815 
    2816         ret = lan78xx_mac_prepare_for_phy(dev);
    2817         if (ret < 0)
    2818                 goto free_phy;
    2819 
    2820         /* if phyirq is not set, use polling mode in phylib */
    2821         if (dev->domain_data.phyirq > 0)
    2822                 phydev->irq = dev->domain_data.phyirq;
    2823         else
    2824                 phydev->irq = PHY_POLL;
    2825         netdev_dbg(dev->net, "phydev->irq = %d\n", phydev->irq);
    2826 
    2827         /* set to AUTOMDIX */
    2828         phydev->mdix = ETH_TP_MDI_AUTO;
    2829 
    2830         ret = phy_connect_direct(dev->net, phydev,
    2831                                  lan78xx_link_status_change,
    2832                                  dev->interface);
    2833         if (ret) {
    2834                 netdev_err(dev->net, "can't attach PHY to %s\n",
    2835                            dev->mdiobus->id);
    2836                 if (dev->chipid == ID_REV_CHIP_ID_7801_) {
    2837                         if (phy_is_pseudo_fixed_link(phydev)) {
    2838                                 fixed_phy_unregister(phydev);
    2839                                 phy_device_free(phydev);
    2840                         }
    2841                 }

Why does this error path only cleanup for ID_REV_CHIP_ID_7801_ where the
others do it unconditionally?

--> 2842                 return -EIO;
    2843         }
    2844 
    2845         /* MAC doesn't support 1000T Half */
    2846         phy_remove_link_mode(phydev, ETHTOOL_LINK_MODE_1000baseT_Half_BIT);
    2847 
    2848         /* support both flow controls */
    2849         dev->fc_request_control = (FLOW_CTRL_RX | FLOW_CTRL_TX);
    2850         linkmode_clear_bit(ETHTOOL_LINK_MODE_Pause_BIT,
    2851                            phydev->advertising);
    2852         linkmode_clear_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT,
    2853                            phydev->advertising);
    2854         mii_adv = (u32)mii_advertise_flowctrl(dev->fc_request_control);
    2855         mii_adv_to_linkmode_adv_t(fc, mii_adv);
    2856         linkmode_or(phydev->advertising, fc, phydev->advertising);
    2857 
    2858         phy_support_eee(phydev);
    2859 
    2860         ret = lan78xx_configure_leds_from_dt(dev, phydev);
    2861         if (ret)
    2862                 goto free_phy;
    2863 
    2864         genphy_config_aneg(phydev);
    2865 
    2866         dev->fc_autoneg = phydev->autoneg;
    2867 
    2868         return 0;
    2869 
    2870 free_phy:
    2871         if (phy_is_pseudo_fixed_link(phydev)) {
    2872                 fixed_phy_unregister(phydev);
    2873                 phy_device_free(phydev);
    2874         }
    2875 
    2876         return ret;
    2877 }

regards,
dan carpenter




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux