public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wifi: rt2x00usb: fix devres lifetime
@ 2026-03-27 10:47 Johan Hovold
  2026-03-27 11:07 ` Stanislaw Gruszka
  0 siblings, 1 reply; 3+ messages in thread
From: Johan Hovold @ 2026-03-27 10:47 UTC (permalink / raw)
  To: Stanislaw Gruszka
  Cc: linux-wireless, linux-kernel, Johan Hovold, stable,
	Jakob Unterwurzacher

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: 9f2d3eae88d2 ("can: ucan: add driver for Theobroma Systems UCAN devices")
Cc: stable@vger.kernel.org	# 4.19
Cc: Jakob Unterwurzacher <jakob.unterwurzacher@theobroma-systems.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
index 83d00b6baf64..174d89b0b1d7 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
@@ -826,7 +826,7 @@ int rt2x00usb_probe(struct usb_interface *usb_intf,
 	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) {
-- 
2.52.0


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

* Re: [PATCH] wifi: rt2x00usb: fix devres lifetime
  2026-03-27 10:47 [PATCH] wifi: rt2x00usb: fix devres lifetime Johan Hovold
@ 2026-03-27 11:07 ` Stanislaw Gruszka
  2026-03-27 11:28   ` Johan Hovold
  0 siblings, 1 reply; 3+ messages in thread
From: Stanislaw Gruszka @ 2026-03-27 11:07 UTC (permalink / raw)
  To: Johan Hovold; +Cc: linux-wireless, linux-kernel, stable, Jakob Unterwurzacher

Hi

On Fri, Mar 27, 2026 at 11:47:26AM +0100, Johan Hovold wrote:
> 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: 9f2d3eae88d2 ("can: ucan: add driver for Theobroma Systems UCAN devices")

Fix tag is wrong (and also cc based on it). Tag should be:
8b4c0009313f ("rt2x00usb: Use usb anchor to manage URB").

Regards
Stanislaw

> Cc: stable@vger.kernel.org	# 4.19
> Cc: Jakob Unterwurzacher <jakob.unterwurzacher@theobroma-systems.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>  drivers/net/wireless/ralink/rt2x00/rt2x00usb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
> index 83d00b6baf64..174d89b0b1d7 100644
> --- a/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
> +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00usb.c
> @@ -826,7 +826,7 @@ int rt2x00usb_probe(struct usb_interface *usb_intf,
>  	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) {
> -- 
> 2.52.0
> 

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

* Re: [PATCH] wifi: rt2x00usb: fix devres lifetime
  2026-03-27 11:07 ` Stanislaw Gruszka
@ 2026-03-27 11:28   ` Johan Hovold
  0 siblings, 0 replies; 3+ messages in thread
From: Johan Hovold @ 2026-03-27 11:28 UTC (permalink / raw)
  To: Stanislaw Gruszka
  Cc: linux-wireless, linux-kernel, stable, Jakob Unterwurzacher

On Fri, Mar 27, 2026 at 12:07:30PM +0100, Stanislaw Gruszka wrote:
> Hi
> 
> On Fri, Mar 27, 2026 at 11:47:26AM +0100, Johan Hovold wrote:
> > 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: 9f2d3eae88d2 ("can: ucan: add driver for Theobroma Systems UCAN devices")
> 
> Fix tag is wrong (and also cc based on it). Tag should be:
> 8b4c0009313f ("rt2x00usb: Use usb anchor to manage URB").

Of course, thanks for catching that. I'll send a v2.

Johan

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

end of thread, other threads:[~2026-03-27 11:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-27 10:47 [PATCH] wifi: rt2x00usb: fix devres lifetime Johan Hovold
2026-03-27 11:07 ` Stanislaw Gruszka
2026-03-27 11:28   ` Johan Hovold

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox