* [PATCH] net: usb: pegasus: fix memory leak on usb_submit_urb() failure
@ 2025-12-16 18:41 Petko Manolov
2025-12-16 18:43 ` kernel test robot
2025-12-23 11:44 ` Paolo Abeni
0 siblings, 2 replies; 6+ 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] 6+ 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-16 18:43 ` kernel test robot
2025-12-23 11:44 ` Paolo Abeni
1 sibling, 0 replies; 6+ messages in thread
From: kernel test robot @ 2025-12-16 18:43 UTC (permalink / raw)
To: Petko Manolov; +Cc: stable, oe-kbuild-all
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1
Rule: add the tag "Cc: stable@vger.kernel.org" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH] net: usb: pegasus: fix memory leak on usb_submit_urb() failure
Link: https://lore.kernel.org/stable/20251216184113.197439-1-petko.manolov%40konsulko.com
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 6+ 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-16 18:43 ` kernel test robot
@ 2025-12-23 11:44 ` Paolo Abeni
2026-01-02 12:10 ` Petko Manolov
1 sibling, 1 reply; 6+ 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] 6+ 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; 6+ 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] 6+ 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
2026-01-06 9:15 ` Petko Manolov
0 siblings, 1 reply; 6+ 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] 6+ messages in thread
* Re: [PATCH] net: usb: pegasus: fix memory leak on usb_submit_urb() failure
2026-01-02 22:02 ` Andrew Lunn
@ 2026-01-06 9:15 ` Petko Manolov
0 siblings, 0 replies; 6+ messages in thread
From: Petko Manolov @ 2026-01-06 9:15 UTC (permalink / raw)
To: Andrew Lunn; +Cc: Paolo Abeni, davem, netdev, kuba, stable
On 26-01-02 23:02:53, Andrew Lunn wrote:
> > 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.
Heh, __free() is OK for APIs, but not drivers...
Maybe this text is a relic from the times auto cleanup was not fully understood?
Petko
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-01-06 9:15 UTC | newest]
Thread overview: 6+ 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-16 18:43 ` kernel test robot
2025-12-23 11:44 ` Paolo Abeni
2026-01-02 12:10 ` Petko Manolov
2026-01-02 22:02 ` Andrew Lunn
2026-01-06 9:15 ` Petko Manolov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox