Skip to contentSkip to conversation

wifi: rtw88: usb: stop RX work before unregistering hardware

PATCH In review Zhao Li 3 participants 4 messages Nov 1 – Nov 12

Subsystems (2)
lore
Share & tools
lore

Zhao Li

author
#0 lore raw

PATCH v2 1/1 wifi: rtw88: usb: stop RX work before unregistering hardware

Disconnecting an rtw88 USB device while RX traffic is active can leave the RX worker running after mac80211 hardware is unregistered. A firmware event can then queue C2H work onto a destroyed workqueue.

rtw_usb_disconnect() kills the RX URBs but does not cancel rx_work, which their completions may already have queued. rxwq is destroyed only after rtw_unregister_hw().

Cancel rx_work synchronously after killing the RX URBs. Only a successful RX completion queues rx_work, and no RX URB can be resubmitted at this point: rtw88 does not set soft_unbind, so the USB core disables the endpoints before it calls rtw_usb_disconnect().

LLM assistance was used to find the bug and review.

Fixes a82dfd33d123 ("wifi: rtw88: Add common USB chip support")

---
Changes in v2:
- Drop disable_work_sync(&rtwusb->rx_urb_work): the endpoints are already disabled, so rx_urb_work cannot restart a killed URB (Luka)
- Correct the commit message accordingly
- Drop the 3e3aa566dd18 Fixes tag and the stable backport note; the patch now applies unchanged to 6.6.y and later

v1: https://lore.kernel.org/r/[email protected]

Validation: A W=1 build of usb.o passed. Not reproduced; rtw88 USB hardware was unavailable.
Sparse C=2 and Smatch introduced no new diagnostics.

 drivers/net/wireless/realtek/rtw88/usb.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/realtek/rtw88/usb.c +1 -0
index 64e1c3420e0a..56ca4496b2e6 100644
@@ -1371,6 +1371,7 @@ void rtw_usb_disconnect(struct usb_interface *intf)
 	rtwusb = rtw_get_usb_priv(rtwdev);
 
 	rtw_usb_cancel_rx_bufs(rtwusb);
+	cancel_work_sync(&rtwusb->rx_work);
 
 	rtw_unregister_hw(rtwdev, hw);
 	rtw_usb_deinit_tx(rtwdev);

base-commit: af32da41b0327b9c6a37856ba82b6760d6c8d10e

Signature · 1 line
2.56.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 14 lines · Zhao Li

Disconnecting an rtw88 USB device while RX traffic is active can leave the RX worker running after mac80211 hardware is unregistered. A firmware event can then queue C2H work onto a destroyed workqueue.

rtw_usb_disconnect() kills the RX URBs but does not cancel rx_work, which their completions may already have queued. rxwq is destroyed only after rtw_unregister_hw().

Cancel rx_work synchronously after killing the RX URBs. Only a successful RX completion queues rx_work, and no RX URB can be resubmitted at this point: rtw88 does not set soft_unbind, so the USB core disables the endpoints before it calls rtw_usb_disconnect().

Quoted 6 lines

LLM assistance was used to find the bug and review.

Fixes a82dfd33d123 ("wifi: rtw88: Add common USB chip support")

---

Looking good to me.

Best regards,
Luka Gejak

maintainer Acked-by on v2 1/1
#2 lore raw
In reply to Zhao Li
Quoted 13 lines · Zhao Li

Disconnecting an rtw88 USB device while RX traffic is active can leave the RX worker running after mac80211 hardware is unregistered. A firmware event can then queue C2H work onto a destroyed workqueue.

rtw_usb_disconnect() kills the RX URBs but does not cancel rx_work, which their completions may already have queued. rxwq is destroyed only after rtw_unregister_hw().

Cancel rx_work synchronously after killing the RX URBs. Only a successful RX completion queues rx_work, and no RX URB can be resubmitted at this point: rtw88 does not set soft_unbind, so the USB core disables the endpoints before it calls rtw_usb_disconnect().

Quoted 5 lines

LLM assistance was used to find the bug and review.

Fixes a82dfd33d123 ("wifi: rtw88: Add common USB chip support")
maintainer
#3 lore raw
In reply to Zhao Li
Quoted 13 lines · Zhao Li

Disconnecting an rtw88 USB device while RX traffic is active can leave the RX worker running after mac80211 hardware is unregistered. A firmware event can then queue C2H work onto a destroyed workqueue.

rtw_usb_disconnect() kills the RX URBs but does not cancel rx_work, which their completions may already have queued. rxwq is destroyed only after rtw_unregister_hw().

Cancel rx_work synchronously after killing the RX URBs. Only a successful RX completion queues rx_work, and no RX URB can be resubmitted at this point: rtw88 does not set soft_unbind, so the USB core disables the endpoints before it calls rtw_usb_disconnect().

Quoted 6 lines

LLM assistance was used to find the bug and review.

Fixes a82dfd33d123 ("wifi: rtw88: Add common USB chip support")

1 patch(es) applied to rtw-next branch of rtw.git, thanks.

85ef46b9f514 wifi: rtw88: usb: stop RX work before unregistering hardware

---
https://github.com/pkshih/rtw.git