USB: sierra: Fix urb leak in sierra_submit_delayed_urbs()
Subsystems (3)
PATCH 1/1 USB: sierra: Fix urb leak in sierra_submit_delayed_urbs()
sierra_submit_delayed_urbs() takes a reference to each delayed urb with usb_get_from_anchor() before submitting it. The submit failure path releases the reference with usb_free_urb(), but on the success path the reference is never dropped: the urb is only anchored in the active list and the USB core unanchors it on completion, leaving the reference returned by usb_get_from_anchor() dangling so the urb object is never freed.
Drop the reference with usb_put_urb() after a successful submission, matching the reference handling in sierra_write() and the sierra_close() drain loop. Skip the rest of the loop body with continue on the error path, which already frees the urb.
--- drivers/usb/serial/sierra.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/serial/sierra.c +2 -0
@@ -977,7 +977,9 @@ static int sierra_submit_delayed_urbs(struct usb_serial_port *port)spin_lock (&portdata->lock); portdata->outstanding_urbs--;spin_unlock (&portdata->lock); +continue ; } +usb_put_urb (urb); }if (ec)
Signature · 1 line
2.34.1
Johan Hovold
maintainerQuoted 8 lines · Wentao Liang
sierra_submit_delayed_urbs()takes a reference to each delayed urb withusb_get_from_anchor()before submitting it. The submit failure path releases the reference withusb_free_urb(), but on the success path the reference is never dropped: the urb is only anchored in the active list and the USB core unanchors it on completion, leaving the reference returned byusb_get_from_anchor()dangling so the urb object is never freed.
Quoted 8 lines
Drop the reference with
usb_put_urb()after a successful submission, matching the reference handling insierra_write()and thesierra_close()drain loop. Skip the rest of the loop body with continue on the error path, which already frees the urb.Fixes e6929a9020ac ("USB: support for autosuspend in sierra while online")Signed-off-by Wentao Liang <[email protected]>
This looks correct, but as Greg already asked you elsewhere, did you forget to add an Assisted-by tag here as well? How was this issue found and fixed?
Also, you need to start replying to feedback. According to the list archives you have haven't replied to any of the four mails commenting on your patches that I've sent you so far.
Johan
Johan Hovold
maintainerQuoted 18 lines · Johan Hovold
Quoted 8 lines · Wentao Liang
sierra_submit_delayed_urbs()takes a reference to each delayed urb withusb_get_from_anchor()before submitting it. The submit failure path releases the reference withusb_free_urb(), but on the success path the reference is never dropped: the urb is only anchored in the active list and the USB core unanchors it on completion, leaving the reference returned byusb_get_from_anchor()dangling so the urb object is never freed.Quoted 8 lines
Drop the reference with
usb_put_urb()after a successful submission, matching the reference handling insierra_write()and thesierra_close()drain loop. Skip the rest of the loop body with continue on the error path, which already frees the urb.Fixes e6929a9020ac ("USB: support for autosuspend in sierra while online")Signed-off-by Wentao Liang <[email protected]>
Quoted 7 lines
This looks correct, but as Greg already asked you elsewhere, did you forget to add an Assisted-by tag here as well? How was this issue found and fixed?
Also, you need to start replying to feedback. According to the list archives you have haven't replied to any of the four mails commenting on your patches that I've sent you so far.
You still haven't replied to anything I've ever sent you so I'm gonna start treating you like a bot.
I've fixed up the USB serial and cdc-acm leaks you reported and given you credit for reporting them.
Johan
Hi Johan,
Sorry for the very late reply - a month since this one, and seven weeks since your first mail - and for the mess I left behind. Thank you for the review and for the corrections. You are right about all of it, including that I had not replied to a single mail you ever sent me. Concluding from the archives that I was behaving like a bot was a reasonable call, and it should not have taken that to get an answer out of me.
On the patch: you are right that the reference returned by usb_get_from_anchor() has to be dropped as a put, and that sierra_close() already did it while the resume path did not. I see you fixed it yourself in e7daa54802c5 ("USB: serial: sierra: fix urb leak on write completion"); it is in mainline and has already been queued for stable. Thank you for that, and for the Reported-by credit - I am sorry you had to spend your time writing a fix that I should have sent correctly and then followed up on. I am not resending anything for this thread, and patchwork 14822917 can be dropped.
On the Assisted-by tag: I have not been adding one. Instead I describe the workflow in the changelog text, which is what Documentation/process/generated-content.rst asks for. What I write there is that the candidates come from static analysis tooling we run over the kernel, and that DeepSeek and GPT-6.1 Sol were used to audit those candidates and to help write the fixes. I review and build-test every patch before sending it, and I am responsible for all of it. That description will be in the changelog of anything I send from now on.
The real problem was not the patches themselves but the volume: I was posting faster than I could read the replies, and then I stopped reading them at all. I am going through the outstanding comments by hand now, one thread at a time, and answering them before I write anything new. I will not send patches in bulk again, on this list or any other.
Thanks,
Wentao