mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolai Buchwitz <nb@tipi-net.de>
To: Stefano Munari <stefanomunari.sm@gmail.com>
Cc: Thangaraj Samynathan <Thangaraj.S@microchip.com>,
	UNGLinuxDriver@microchip.com, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	netdev@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net: usb: lan78xx: fix error handling in lan78xx_open()
Date: Mon, 19 Oct 2026 13:25:12 +0200	[thread overview]
Message-ID: <7b05d39d4674c16065b03f88b1ccfd05@tipi-net.de> (raw)
In-Reply-To: <20261016000521.92868-1-stefanomunari.sm@gmail.com>

Hi Stefano

On 16.10.2026 02:05, Stefano Munari wrote:
> A failed interrupt URB submission leaves NAPI enabled and 
> EVENT_DEV_OPEN
> set. A subsequent open enables NAPI again, triggering BUG_ON() in
> napi_enable().
> 
> Clear EVENT_DEV_OPEN and disable NAPI on the submission error path.
> 
> Reproduced using failslab on a Raspberry Pi 3 Model B+ (LAN7515).
> With the fix, the injected allocation failure returns -ENOMEM and a
> subsequent open succeeds. Verified connectivity with ping and SSH.
> 
> Fixes: e110bc825897 ("net: usb: lan78xx: Convert to PHYLINK for 
> improved PHY and MAC management")
> Signed-off-by: Stefano Munari <stefanomunari.sm@gmail.com>
> ---
>  drivers/net/usb/lan78xx.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
> index 5655941f1478..6a95934bb3d3 100644
> --- a/drivers/net/usb/lan78xx.c
> +++ b/drivers/net/usb/lan78xx.c
> @@ -3484,6 +3484,8 @@ static int lan78xx_open(struct net_device *net)
>  		if (ret < 0) {
>  			netif_err(dev, ifup, dev->net,
>  				  "intr submit %d\n", ret);
> +			clear_bit(EVENT_DEV_OPEN, &dev->flags);
> +			napi_disable(&dev->napi);
>  			goto done;
>  		}
>  	}

Looks correct to me. Maybe move the cleanup into an unwind label, so
the next error path added after napi_enable() doesn't miss it?

                 if (ret < 0) {
                         netif_err(dev, ifup, dev->net,
                                   "intr submit %d\n", ret);
                         goto err_napi;
                 }
         }

         phylink_start(dev->phylink);
         mutex_unlock(&dev->dev_mutex);

         return 0;

err_napi:
         clear_bit(EVENT_DEV_OPEN, &dev->flags);
         napi_disable(&dev->napi);
         mutex_unlock(&dev->dev_mutex);
         usb_autopm_put_interface(dev->intf);

         return ret;

Either way:

Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>

Thanks,
Nicolai

      reply	other threads:[~2026-10-19 11:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16  0:05 Stefano Munari
2026-10-19 11:25 ` Nicolai Buchwitz [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=7b05d39d4674c16065b03f88b1ccfd05@tipi-net.de \
    --to=nb@tipi-net.de \
    --cc=Thangaraj.S@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=stefanomunari.sm@gmail.com \
    /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

all inboxes | Powered by JetHome®