All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtlwifi: rtl_usb: Fix for URB leaking when doing ifconfig up/down
@ 2017-01-26 17:25 Larry Finger
  2017-01-28  7:11 ` Kalle Valo
  0 siblings, 1 reply; 2+ messages in thread
From: Larry Finger @ 2017-01-26 17:25 UTC (permalink / raw)
  To: kvalo; +Cc: linux-wireless, Michael Schenk, Larry Finger, Stable

From: Michael Schenk <michael.schenk@albis-elcon.com>

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>
Cc: Stable <stable@vger.kernel.org>
---

Kalle,

This fix should be sent upstream whenever possible.

It is an old bug.

Thanks,

Larry
---
 drivers/net/wireless/realtek/rtlwifi/usb.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c
index 0bca263..4d989b8 100644
--- a/drivers/net/wireless/realtek/rtlwifi/usb.c
+++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
@@ -818,12 +818,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);
 }
 
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: rtlwifi: rtl_usb: Fix for URB leaking when doing ifconfig up/down
  2017-01-26 17:25 [PATCH] rtlwifi: rtl_usb: Fix for URB leaking when doing ifconfig up/down Larry Finger
@ 2017-01-28  7:11 ` Kalle Valo
  0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2017-01-28  7:11 UTC (permalink / raw)
  To: Larry Finger; +Cc: linux-wireless, Michael Schenk, Larry Finger, Stable

Larry Finger <Larry.Finger@lwfinger.net> wrote:
> From: Michael Schenk <michael.schenk@albis-elcon.com>
> 
> 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>
> Cc: Stable <stable@vger.kernel.org>

Patch applied to wireless-drivers-next.git, thanks.

575ddce05077 rtlwifi: rtl_usb: Fix for URB leaking when doing ifconfig up/down

-- 
https://patchwork.kernel.org/patch/9539941/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-28  7:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-26 17:25 [PATCH] rtlwifi: rtl_usb: Fix for URB leaking when doing ifconfig up/down Larry Finger
2017-01-28  7:11 ` Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.