| From 25369b22223d1c56e42a0cd4ac9137349d5a898e Mon Sep 17 00:00:00 2001 |
| From: Johan Hovold <johan@kernel.org> |
| Date: Fri, 27 Mar 2026 12:32:19 +0100 |
| Subject: wifi: rt2x00usb: fix devres lifetime |
| |
| From: Johan Hovold <johan@kernel.org> |
| |
| commit 25369b22223d1c56e42a0cd4ac9137349d5a898e upstream. |
| |
| USB drivers bind to USB interfaces and any device managed resources |
| should have their lifetime tied to the interface rather than parent USB |
| device. This avoids issues like memory leaks when drivers are unbound |
| without their devices being physically disconnected (e.g. on probe |
| deferral or configuration changes). |
| |
| Fix the USB anchor lifetime so that it is released on driver unbind. |
| |
| Fixes: 8b4c0009313f ("rt2x00usb: Use usb anchor to manage URB") |
| Cc: stable@vger.kernel.org # 4.7 |
| Cc: Vishal Thanki <vishalthanki@gmail.com> |
| Signed-off-by: Johan Hovold <johan@kernel.org> |
| Acked-by: Stanislaw Gruszka <stf_xl@wp.pl> |
| Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| Link: https://patch.msgid.link/20260327113219.1313748-1-johan@kernel.org |
| Signed-off-by: Johannes Berg <johannes.berg@intel.com> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 2 +- |
| 1 file changed, 1 insertion(+), 1 deletion(-) |
| |
| --- a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c |
| +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c |
| @@ -830,7 +830,7 @@ int rt2x00usb_probe(struct usb_interface |
| if (retval) |
| goto exit_free_device; |
| |
| - rt2x00dev->anchor = devm_kmalloc(&usb_dev->dev, |
| + rt2x00dev->anchor = devm_kmalloc(&usb_intf->dev, |
| sizeof(struct usb_anchor), |
| GFP_KERNEL); |
| if (!rt2x00dev->anchor) { |