Skip to content

Commit 39707c2

Browse files
Hemant Kumardavem330
authored andcommitted
net: usb: Fix memory leak on Tx data path
Driver anchors the tx urbs and defers the urb submission if a transmit request comes when the interface is suspended. Anchoring urb increments the urb reference count. These deferred urbs are later accessed by calling usb_get_from_anchor() for submission during interface resume. usb_get_from_anchor() unanchors the urb but urb reference count remains same. This causes the urb reference count to remain non-zero after usb_free_urb() gets called and urb never gets freed. Hence call usb_put_urb() after anchoring the urb to properly balance the reference count for these deferred urbs. Also, unanchor these deferred urbs during disconnect, to free them up. Signed-off-by: Hemant Kumar <[email protected]> Acked-by: Oliver Neukum <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bfc0d8c commit 39707c2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/net/usb/usbnet.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,7 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
11581158
usb_anchor_urb(urb, &dev->deferred);
11591159
/* no use to process more packets */
11601160
netif_stop_queue(net);
1161+
usb_put_urb(urb);
11611162
spin_unlock_irqrestore(&dev->txq.lock, flags);
11621163
netdev_dbg(dev->net, "Delaying transmission for resumption\n");
11631164
goto deferred;
@@ -1310,6 +1311,8 @@ void usbnet_disconnect (struct usb_interface *intf)
13101311

13111312
cancel_work_sync(&dev->kevent);
13121313

1314+
usb_scuttle_anchored_urbs(&dev->deferred);
1315+
13131316
if (dev->driver_info->unbind)
13141317
dev->driver_info->unbind (dev, intf);
13151318

0 commit comments

Comments
 (0)