Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: f_printer: Fix fsync waiting for active transfers
@ 2026-11-10  3:18 raoxu
  2026-11-10  3:29 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: raoxu @ 2026-11-10  3:18 UTC (permalink / raw)
  To: nkapron
  Cc: gregkh, luiz.von.dentz, brgl, pengpeng, pmenzel, raoxu, mlbnkm1,
	christophe.jaillet, linux-usb, linux-kernel

From: Xu Rao <raoxu@uniontech.com>

printer_fsync() checks the list of free TX requests before deciding
whether to wait for all data to be sent. Once a write queues a request,
it is removed from the free list and placed on tx_reqs_active, so the
free list can be empty while a USB transfer is still in progress.

This allows fsync() to return before the queued data has completed.
Check tx_reqs_active instead, matching the wait condition and the
completion callback that wakes tx_flush_wait.

Signed-off-by: Xu Rao <raoxu@uniontech.com>
---
 drivers/usb/gadget/function/f_printer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c
index 1857d786110b..a2437c8e668d 100644
--- a/drivers/usb/gadget/function/f_printer.c
+++ b/drivers/usb/gadget/function/f_printer.c
@@ -736,7 +736,7 @@ printer_fsync(struct file *fd, loff_t start, loff_t end, int datasync)
 		return -ENODEV;
 	}

-	tx_list_empty = (likely(list_empty(&dev->tx_reqs)));
+	tx_list_empty = (likely(list_empty(&dev->tx_reqs_active)));
 	spin_unlock_irqrestore(&dev->lock, flags);

 	if (!tx_list_empty) {
--
2.50.1



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

end of thread, other threads:[~2026-11-10  3:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-10  3:18 [PATCH] usb: gadget: f_printer: Fix fsync waiting for active transfers raoxu
2026-11-10  3:29 ` sashiko-bot

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