netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: usb: pegasus: fix memory leak on usb_submit_urb() failure
@ 2025-12-16 18:41 Petko Manolov
  2025-12-23 11:44 ` Paolo Abeni
  0 siblings, 1 reply; 4+ messages in thread
From: Petko Manolov @ 2025-12-16 18:41 UTC (permalink / raw)
  To: davem; +Cc: netdev, kuba, stable, Petko Manolov

In update_eth_regs_async() neither the URB nor the request structure are being
freed if usb_submit_urb() fails.  The patch fixes this long lurking bug in the
error path.

Signed-off-by: Petko Manolov <petko.manolov@konsulko.com>
---
 drivers/net/usb/pegasus.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
index 81ca64debc5b..7a70207e7364 100644
--- a/drivers/net/usb/pegasus.c
+++ b/drivers/net/usb/pegasus.c
@@ -168,6 +168,8 @@ static int update_eth_regs_async(pegasus_t *pegasus)
 			netif_device_detach(pegasus->net);
 		netif_err(pegasus, drv, pegasus->net,
 			  "%s returned %d\n", __func__, ret);
+		kfree(req);
+		usb_free_urb(async_urb);
 	}
 	return ret;
 }
-- 
2.52.0


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

* Re: [PATCH] net: usb: pegasus: fix memory leak on usb_submit_urb() failure
  2025-12-16 18:41 [PATCH] net: usb: pegasus: fix memory leak on usb_submit_urb() failure Petko Manolov
@ 2025-12-23 11:44 ` Paolo Abeni
  2026-01-02 12:10   ` Petko Manolov
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Abeni @ 2025-12-23 11:44 UTC (permalink / raw)
  To: Petko Manolov, davem; +Cc: netdev, kuba, stable

On 12/16/25 7:41 PM, Petko Manolov wrote:
> In update_eth_regs_async() neither the URB nor the request structure are being
> freed if usb_submit_urb() fails.  The patch fixes this long lurking bug in the
> error path.
> 
> Signed-off-by: Petko Manolov <petko.manolov@konsulko.com>

Please:
- include the targed tree in the subj prefix ('net' in this case)
- include a suitable Fixes tag

Thanks,

Paolo


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

* Re: [PATCH] net: usb: pegasus: fix memory leak on usb_submit_urb() failure
  2025-12-23 11:44 ` Paolo Abeni
@ 2026-01-02 12:10   ` Petko Manolov
  2026-01-02 22:02     ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: Petko Manolov @ 2026-01-02 12:10 UTC (permalink / raw)
  To: Paolo Abeni; +Cc: davem, netdev, kuba, stable

On 25-12-23 12:44:53, Paolo Abeni wrote:
> On 12/16/25 7:41 PM, Petko Manolov wrote:
> > In update_eth_regs_async() neither the URB nor the request structure are being
> > freed if usb_submit_urb() fails.  The patch fixes this long lurking bug in the
> > error path.
> > 
> > Signed-off-by: Petko Manolov <petko.manolov@konsulko.com>
> 
> Please:
> - include the targed tree in the subj prefix ('net' in this case)
> - include a suitable Fixes tag

Sure, will do.  However, my v2 patch makes use of __free() cleanup
functionality, which in turn only applies back to v6.6 stable kernels.

I guess i shall make another version of the patch that is suitable only for v5.4
to v6.1 stable releases, right?  How shall i format the patch so that it targets
only these old versions?


cheers,
Petko

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

* Re: [PATCH] net: usb: pegasus: fix memory leak on usb_submit_urb() failure
  2026-01-02 12:10   ` Petko Manolov
@ 2026-01-02 22:02     ` Andrew Lunn
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2026-01-02 22:02 UTC (permalink / raw)
  To: Petko Manolov; +Cc: Paolo Abeni, davem, netdev, kuba, stable

> Sure, will do.  However, my v2 patch makes use of __free() cleanup
> functionality, which in turn only applies back to v6.6 stable kernels.

I would suggest not using the magical __free() cleanup.

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html#using-device-managed-and-cleanup-h-constructs

    Low level cleanup constructs (such as __free()) can be used when
    building APIs and helpers, especially scoped iterators. However,
    direct use of __free() within networking core and drivers is
    discouraged. Similar guidance applies to declaring variables
    mid-function.

    Andrew

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

end of thread, other threads:[~2026-01-02 22:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-16 18:41 [PATCH] net: usb: pegasus: fix memory leak on usb_submit_urb() failure Petko Manolov
2025-12-23 11:44 ` Paolo Abeni
2026-01-02 12:10   ` Petko Manolov
2026-01-02 22:02     ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).