Skip to content

Commit 151d4c0

Browse files
Michael Schenkgregkh
authored andcommitted
rtlwifi: rtl_usb: Fix for URB leaking when doing ifconfig up/down
commit 575ddce0507789bf9830d089557d2199d2f91865 upstream. In the function rtl_usb_start we pre-allocate a certain number of urbs for RX path but they will not be freed when calling rtl_usb_stop. This results in leaking urbs when doing ifconfig up and down. Eventually, the system has no available urbs. Signed-off-by: Michael Schenk <michael.schenk@albis-elcon.com> Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent de56348 commit 151d4c0

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

  • drivers/net/wireless/realtek/rtlwifi

drivers/net/wireless/realtek/rtlwifi/usb.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,12 +834,30 @@ static void rtl_usb_stop(struct ieee80211_hw *hw)
834834
struct rtl_priv *rtlpriv = rtl_priv(hw);
835835
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
836836
struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
837+
struct urb *urb;
837838

838839
/* should after adapter start and interrupt enable. */
839840
set_hal_stop(rtlhal);
840841
cancel_work_sync(&rtlpriv->works.fill_h2c_cmd);
841842
/* Enable software */
842843
SET_USB_STOP(rtlusb);
844+
845+
/* free pre-allocated URBs from rtl_usb_start() */
846+
usb_kill_anchored_urbs(&rtlusb->rx_submitted);
847+
848+
tasklet_kill(&rtlusb->rx_work_tasklet);
849+
cancel_work_sync(&rtlpriv->works.lps_change_work);
850+
851+
flush_workqueue(rtlpriv->works.rtl_wq);
852+
853+
skb_queue_purge(&rtlusb->rx_queue);
854+
855+
while ((urb = usb_get_from_anchor(&rtlusb->rx_cleanup_urbs))) {
856+
usb_free_coherent(urb->dev, urb->transfer_buffer_length,
857+
urb->transfer_buffer, urb->transfer_dma);
858+
usb_free_urb(urb);
859+
}
860+
843861
rtlpriv->cfg->ops->hw_disable(hw);
844862
}
845863

0 commit comments

Comments
 (0)