Skip to content

Commit 580db27

Browse files
ammarfaizi2gregkh
authored andcommitted
net: usbnet: Fix the wrong netif_carrier_on() call
commit 8466d39 upstream. The commit referenced in the Fixes tag causes usbnet to malfunction (identified via git bisect). Post-commit, my external RJ45 LAN cable fails to connect. Linus also reported the same issue after pulling that commit. The code has a logic error: netif_carrier_on() is only called when the link is already on. Fix this by moving the netif_carrier_on() call outside the if-statement entirely. This ensures it is always called when EVENT_LINK_CARRIER_ON is set and properly clears it regardless of the link state. Cc: stable@vger.kernel.org Cc: Armando Budianto <sprite@gnuweeb.org> Reviewed-by: Simon Horman <horms@kernel.org> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/all/CAHk-=wjqL4uF0MG_c8+xHX1Vv8==sPYQrtzbdA3kzi96284nuQ@mail.gmail.com Closes: https://lore.kernel.org/netdev/CAHk-=wjKh8X4PT_mU1kD4GQrbjivMfPn-_hXa6han_BTDcXddw@mail.gmail.com Closes: https://lore.kernel.org/netdev/0752dee6-43d6-4e1f-81d2-4248142cccd2@gnuweeb.org Fixes: 0d9cfc9 ("net: usbnet: Avoid potential RCU stall on LINK_CHANGE event") Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 87957b4 commit 580db27

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/net/usb/usbnet.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,9 @@ static void __handle_link_change(struct usbnet *dev)
11131113
if (!test_bit(EVENT_DEV_OPEN, &dev->flags))
11141114
return;
11151115

1116+
if (test_and_clear_bit(EVENT_LINK_CARRIER_ON, &dev->flags))
1117+
netif_carrier_on(dev->net);
1118+
11161119
if (!netif_carrier_ok(dev->net)) {
11171120
/* kill URBs for reading packets to save bus bandwidth */
11181121
unlink_urbs(dev, &dev->rxq);
@@ -1122,9 +1125,6 @@ static void __handle_link_change(struct usbnet *dev)
11221125
* tx queue is stopped by netcore after link becomes off
11231126
*/
11241127
} else {
1125-
if (test_and_clear_bit(EVENT_LINK_CARRIER_ON, &dev->flags))
1126-
netif_carrier_on(dev->net);
1127-
11281128
/* submitting URBs for reading packets */
11291129
tasklet_schedule(&dev->bh);
11301130
}

0 commit comments

Comments
 (0)