Skip to content

Commit 51de360

Browse files
Ying Lukuba-moo
authored andcommitted
usbnet:fix NPE during rx_complete
Missing usbnet_going_away Check in Critical Path. The usb_submit_urb function lacks a usbnet_going_away validation, whereas __usbnet_queue_skb includes this check. This inconsistency creates a race condition where: A URB request may succeed, but the corresponding SKB data fails to be queued. Subsequent processes: (e.g., rx_complete → defer_bh → __skb_unlink(skb, list)) attempt to access skb->next, triggering a NULL pointer dereference (Kernel Panic). Fixes: 04e9068 ("usbnet: fix cyclical race on disconnect with work queue") Cc: [email protected] Signed-off-by: Ying Lu <[email protected]> Link: https://patch.msgid.link/4c9ef2efaa07eb7f9a5042b74348a67e5a3a7aea.1743584159.git.luying1@xiaomi.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2a83777 commit 51de360

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/net/usb/usbnet.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,8 @@ static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
530530
netif_device_present (dev->net) &&
531531
test_bit(EVENT_DEV_OPEN, &dev->flags) &&
532532
!test_bit (EVENT_RX_HALT, &dev->flags) &&
533-
!test_bit (EVENT_DEV_ASLEEP, &dev->flags)) {
533+
!test_bit (EVENT_DEV_ASLEEP, &dev->flags) &&
534+
!usbnet_going_away(dev)) {
534535
switch (retval = usb_submit_urb (urb, GFP_ATOMIC)) {
535536
case -EPIPE:
536537
usbnet_defer_kevent (dev, EVENT_RX_HALT);
@@ -551,8 +552,7 @@ static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
551552
tasklet_schedule (&dev->bh);
552553
break;
553554
case 0:
554-
if (!usbnet_going_away(dev))
555-
__usbnet_queue_skb(&dev->rxq, skb, rx_start);
555+
__usbnet_queue_skb(&dev->rxq, skb, rx_start);
556556
}
557557
} else {
558558
netif_dbg(dev, ifdown, dev->net, "rx: stopped\n");

0 commit comments

Comments
 (0)