mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: printer: clear current RX request on unbind
@ 2026-10-24  5:51 Elliot Alderson
  2026-10-24  6:09 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Elliot Alderson @ 2026-10-24  5:51 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, syzbot+ffc483dc87891d3c107b, syzkaller-bugs

printer_func_unbind() frees current_rx_req but leaves the pointer in
printer_dev. A later unbind can then pass the stale pointer to
printer_req_free() again. Clear the saved request and its associated read
state before freeing it.

Fixes: b185f01a9ab7 ("usb: gadget: printer: factor out f_printer")
Reported-by: syzbot+ffc483dc87891d3c107b@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=ffc483dc87891d3c107b
Signed-off-by: Eduard Zateev <hackerowskiy@gmail.com>
---
 drivers/usb/gadget/function/f_printer.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/f_printer.c
b/drivers/usb/gadget/function/f_printer.c
index 1857d786110..11471bd065c 100644
--- a/drivers/usb/gadget/function/f_printer.c
+++ b/drivers/usb/gadget/function/f_printer.c
@@ -1462,8 +1462,11 @@ static void printer_func_unbind(struct
usb_configuration *c,
         printer_req_free(dev->in_ep, req);
     }

-    if (dev->current_rx_req != NULL)
-        printer_req_free(dev->out_ep, dev->current_rx_req);
+    req = dev->current_rx_req;
+    dev->current_rx_req = NULL;
+    dev->current_rx_bytes = 0;
+    dev->current_rx_buf = NULL;
+    printer_req_free(dev->out_ep, req);

     while (!list_empty(&dev->rx_reqs)) {
         req = container_of(dev->rx_reqs.next,
-- 
2.55.0

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

* Re: [PATCH] usb: gadget: printer: clear current RX request on unbind
  2026-10-24  5:51 [PATCH] usb: gadget: printer: clear current RX request on unbind Elliot Alderson
@ 2026-10-24  6:09 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2026-10-24  6:09 UTC (permalink / raw)
  To: Elliot Alderson
  Cc: linux-usb, linux-kernel, syzbot+ffc483dc87891d3c107b, syzkaller-bugs

On Sat, Oct 24, 2026 at 03:51:46PM +1000, Elliot Alderson wrote:
> printer_func_unbind() frees current_rx_req but leaves the pointer in
> printer_dev. A later unbind can then pass the stale pointer to
> printer_req_free() again. Clear the saved request and its associated read
> state before freeing it.
> 
> Fixes: b185f01a9ab7 ("usb: gadget: printer: factor out f_printer")
> Reported-by: syzbot+ffc483dc87891d3c107b@syzkaller.appspotmail.com
> Link: https://syzkaller.appspot.com/bug?extid=ffc483dc87891d3c107b
> Signed-off-by: Eduard Zateev <hackerowskiy@gmail.com>
> ---
>  drivers/usb/gadget/function/f_printer.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/f_printer.c
> b/drivers/usb/gadget/function/f_printer.c
> index 1857d786110..11471bd065c 100644
> --- a/drivers/usb/gadget/function/f_printer.c
> +++ b/drivers/usb/gadget/function/f_printer.c
> @@ -1462,8 +1462,11 @@ static void printer_func_unbind(struct
> usb_configuration *c,
>          printer_req_free(dev->in_ep, req);
>      }
> 
> -    if (dev->current_rx_req != NULL)
> -        printer_req_free(dev->out_ep, dev->current_rx_req);
> +    req = dev->current_rx_req;
> +    dev->current_rx_req = NULL;
> +    dev->current_rx_bytes = 0;
> +    dev->current_rx_buf = NULL;
> +    printer_req_free(dev->out_ep, req);
> 
>      while (!list_empty(&dev->rx_reqs)) {
>          req = container_of(dev->rx_reqs.next,
> -- 
> 2.55.0

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- You have marked a patch with a "Fixes:" tag for a commit that is in an
  older released kernel, yet you do not have a cc: stable line in the
  signed-off-by area at all, which means that the patch will not be
  applied to any older kernel releases.  To properly fix this, please
  follow the documented rules in the
  Documentation/process/stable-kernel-rules.rst file for how to resolve
  this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

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

end of thread, other threads:[~2026-10-24  6:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-24  5:51 [PATCH] usb: gadget: printer: clear current RX request on unbind Elliot Alderson
2026-10-24  6:09 ` Greg Kroah-Hartman

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

all inboxes | Powered by JetHome®