mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] usb: gadget: m66592-udc: recheck ep->queue after reacquiring lock
@ 2026-11-30 10:34 Ziheng Wei
  2026-11-30 10:34 ` [PATCH 2/2] usb: gadget: r8a66597-udc: " Ziheng Wei
  0 siblings, 1 reply; 2+ messages in thread
From: Ziheng Wei @ 2026-11-30 10:34 UTC (permalink / raw)
  To: Neill Kapron, Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel

In transfer_complete(), restart is computed from !list_empty(&ep->queue)
before dropping ep->m66592->lock for usb_gadget_giveback_request(). While
unlocked, the completion callback or a concurrent m66592_dequeue() can
empty ep->queue while ep->ep.desc remains set, causing list_entry() to
pass a bogus pointer to start_packet() once the lock is reacquired.

Recheck !list_empty(&ep->queue) after reacquiring ep->m66592->lock.

Found by LLM-assisted static analysis and runtime-tested in QEMU+KASAN
(null-ptr-deref Oops in start_packet() before the fix; 0 findings after).

Signed-off-by: Ziheng Wei <zihengw03@163.com>
---
 drivers/usb/gadget/udc/m66592-udc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/m66592-udc.c b/drivers/usb/gadget/udc/m66592-udc.c
index d77c11c4e..97cca8442 100644
--- a/drivers/usb/gadget/udc/m66592-udc.c
+++ b/drivers/usb/gadget/udc/m66592-udc.c
@@ -729,7 +729,7 @@ __acquires(m66592->lock)
 	usb_gadget_giveback_request(&ep->ep, &req->req);
 	spin_lock(&ep->m66592->lock);
 
-	if (restart) {
+	if (restart && !list_empty(&ep->queue)) {
 		req = list_entry(ep->queue.next, struct m66592_request, queue);
 		if (ep->ep.desc)
 			start_packet(ep, req);

base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa
-- 
2.43.0


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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 10:34 [PATCH 1/2] usb: gadget: m66592-udc: recheck ep->queue after reacquiring lock Ziheng Wei
2026-11-30 10:34 ` [PATCH 2/2] usb: gadget: r8a66597-udc: " Ziheng Wei

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®