From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server-vie001.gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_ZEN_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=new2025; t=1754075014; bh=FaGTwrEKwK7M7Dbun3EZiMSSgUMwYY7IOVqXCmRjdBk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding:Message-ID:Date:From:Reply-To:Subject:To: Cc:In-Reply-To:References:Resent-Date:Resent-From:Resent-To: Resent-Cc:User-Agent:Content-Type:Content-Transfer-Encoding; b=ElPJ10iSj97Mm8ptfHfOgnuRfC/eYEGLVJVMd6OtYmhBv3OooQar/4ZoBweiERzHS 3TAiZpka87YfhMrUoYF105QxGXZNx4/1oTV29zRW8Bj7dfXT8JlKiLeU5GaL7XylR+ oGrHRynOH1pBwW7oGHI7Kg9Bfxxko/r6tJ1dxxw3RxXs69jZ07AYz0BmcYOZSJNt0V mpRIcGgcV4TR0SvZLHGBwtXqKV/viucOknDlnwTCwoDuJddMiRFrkpmcImFSS2VZeR KJthfK8aUuMv5QAo4j4F+mMb97H8Rb9mm31itgX0I4VZWj9C2l6MKKxt1NfogrguLx N5yTD+wDicbNg== Received: from integral2.. (unknown [182.253.126.229]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id E01813126FD2; Fri, 1 Aug 2025 19:03:30 +0000 (UTC) From: Ammar Faizi To: Oliver Neukum , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Ammar Faizi , Greg Kroah-Hartman , Linux Netdev Mailing List , Linux USB Mailing List , Linux Kernel Mailing List , Armando Budianto , gwml@vger.gnuweeb.org, stable@vger.kernel.org Subject: [PATCH net v2] net: usbnet: Fix the wrong netif_carrier_on() call placement Date: Sat, 2 Aug 2025 02:03:10 +0700 Message-Id: <20250801190310.58443-1-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: The commit in the Fixes tag breaks my laptop (found by git bisect). My home RJ45 LAN cable cannot connect after that commit. The call to netif_carrier_on() should be done when netif_carrier_ok() is false. Not when it's true. Because calling netif_carrier_on() when __LINK_STATE_NOCARRIER is not set actually does nothing. Cc: Armando Budianto Cc: stable@vger.kernel.org Closes: https://lore.kernel.org/netdev/0752dee6-43d6-4e1f-81d2-4248142cccd2@gnuweeb.org Fixes: 0d9cfc9b8cb1 ("net: usbnet: Avoid potential RCU stall on LINK_CHANGE event") Signed-off-by: Ammar Faizi --- v2: - Rebase on top of the latest netdev/net tree. The previous patch was based on 0d9cfc9b8cb1. Line numbers have changed since then. drivers/net/usb/usbnet.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index a38ffbf4b3f0..a1827684b92c 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -1114,31 +1114,31 @@ static const struct ethtool_ops usbnet_ethtool_ops = { }; /*-------------------------------------------------------------------------*/ static void __handle_link_change(struct usbnet *dev) { if (!test_bit(EVENT_DEV_OPEN, &dev->flags)) return; if (!netif_carrier_ok(dev->net)) { + if (test_and_clear_bit(EVENT_LINK_CARRIER_ON, &dev->flags)) + netif_carrier_on(dev->net); + /* kill URBs for reading packets to save bus bandwidth */ unlink_urbs(dev, &dev->rxq); /* * tx_timeout will unlink URBs for sending packets and * tx queue is stopped by netcore after link becomes off */ } else { - if (test_and_clear_bit(EVENT_LINK_CARRIER_ON, &dev->flags)) - netif_carrier_on(dev->net); - /* submitting URBs for reading packets */ queue_work(system_bh_wq, &dev->bh_work); } /* hard_mtu or rx_urb_size may change during link change */ usbnet_update_max_qlen(dev); clear_bit(EVENT_LINK_CHANGE, &dev->flags); } -- Ammar Faizi