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

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®