Skip to content

Commit

Permalink
rtlwifi: rtl_usb: Fix for URB leaking when doing ifconfig up/down
Browse files Browse the repository at this point in the history
commit 575ddce 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>
  • Loading branch information
Michael Schenk authored and Greg Kroah-Hartman committed Feb 26, 2017
1 parent dea972f commit c1f105b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions drivers/net/wireless/realtek/rtlwifi/usb.c
Original file line number Diff line number Diff line change
@@ -827,12 +827,30 @@ static void rtl_usb_stop(struct ieee80211_hw *hw)
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
struct urb *urb;

/* should after adapter start and interrupt enable. */
set_hal_stop(rtlhal);
cancel_work_sync(&rtlpriv->works.fill_h2c_cmd);
/* Enable software */
SET_USB_STOP(rtlusb);

/* free pre-allocated URBs from rtl_usb_start() */
usb_kill_anchored_urbs(&rtlusb->rx_submitted);

tasklet_kill(&rtlusb->rx_work_tasklet);
cancel_work_sync(&rtlpriv->works.lps_change_work);

flush_workqueue(rtlpriv->works.rtl_wq);

skb_queue_purge(&rtlusb->rx_queue);

while ((urb = usb_get_from_anchor(&rtlusb->rx_cleanup_urbs))) {
usb_free_coherent(urb->dev, urb->transfer_buffer_length,
urb->transfer_buffer, urb->transfer_dma);
usb_free_urb(urb);
}

rtlpriv->cfg->ops->hw_disable(hw);
}

0 comments on commit c1f105b

Please sign in to comment.