public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: linux-usb@vger.kernel.org
Subject: Re: [bug report] net: usb: lan78xx: Convert to PHYLINK for improved PHY and MAC management
Date: Thu, 26 Jun 2025 12:39:31 +0200	[thread overview]
Message-ID: <aF0jY8gUPgYDSyew@pengutronix.de> (raw)
In-Reply-To: <162f8d6d-b2ff-4ad4-96ad-5477a1bb4217@sabinyo.mountain>

On Wed, Jun 25, 2025 at 10:22:54AM -0500, Dan Carpenter wrote:
> Hello Oleksij Rempel,
> 
> The patch e110bc825897: "net: usb: lan78xx: Convert to PHYLINK for
> improved PHY and MAC management" from Jun 18, 2025, leads to the
> following static checker warning:
> 
>     drivers/net/usb/lan78xx.c:2851 lan78xx_phy_init()
>     error: we previously assumed 'phydev' could be null (see line 2839)
> 
> drivers/net/usb/lan78xx.c
>     2817 static int lan78xx_phy_init(struct lan78xx_net *dev)
>     2818 {
>     2819 	struct phy_device *phydev;
>     2820 	int ret;
>     2821 
>     2822 	phydev = lan78xx_get_phy(dev);
>     2823 	/* phydev can be NULL if no PHY is found and the chip is LAN7801,
> 
> Assume phydev is NULL
> 
>     2824 	 * which will use a fixed link later.
>     2825 	 * If an  error occurs, return the error code immediately.
>     2826 	 */
>     2827 	if (IS_ERR(phydev))
>     2828 		return PTR_ERR(phydev);
>     2829 
>     2830 	ret = lan78xx_phylink_setup(dev);
>     2831 	if (ret < 0)
>     2832 		return ret;
>     2833 
>     2834 	/* If no PHY is found, set up a fixed link. It is very specific to
>     2835 	 * the LAN7801 and is used in special cases like EVB-KSZ9897-1 where
>     2836 	 * LAN7801 acts as a USB-to-Ethernet interface to a switch without
>     2837 	 * a visible PHY.
>     2838 	 */
>     2839 	if (!phydev) {
>     2840 		ret = lan78xx_set_fixed_link(dev);
>     2841 		if (ret < 0)
>     2842 			goto phylink_uninit;
>     2843 	}
>     2844 
>     2845 	ret = lan78xx_mac_prepare_for_phy(dev);
>     2846 	if (ret < 0)
>     2847 		goto phylink_uninit;
>     2848 
>     2849 	/* if phyirq is not set, use polling mode in phylib */
>     2850 	if (dev->domain_data.phyirq > 0)
> --> 2851 		phydev->irq = dev->domain_data.phyirq;
>     2852 	else
>     2853 		phydev->irq = PHY_POLL;
>     2854 	netdev_dbg(dev->net, "phydev->irq = %d\n", phydev->irq);
> 
> Then this block will crash.

Thank you for the bug report!

Here is the fix:
https://lore.kernel.org/all/20250626103731.3986545-1-o.rempel@pengutronix.de

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

      reply	other threads:[~2025-06-26 10:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-25 15:22 [bug report] net: usb: lan78xx: Convert to PHYLINK for improved PHY and MAC management Dan Carpenter
2025-06-26 10:39 ` Oleksij Rempel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aF0jY8gUPgYDSyew@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=dan.carpenter@linaro.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox