* [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
2026-11-30 10:46 ` [PATCH 1/2] usb: gadget: m66592-udc: " sashiko-bot
0 siblings, 2 replies; 4+ 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 related [flat|nested] 4+ messages in thread* [PATCH 2/2] usb: gadget: r8a66597-udc: recheck ep->queue after reacquiring lock
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 ` Ziheng Wei
2026-11-30 10:40 ` sashiko-bot
2026-11-30 10:46 ` [PATCH 1/2] usb: gadget: m66592-udc: " sashiko-bot
1 sibling, 1 reply; 4+ 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->r8a66597->lock for usb_gadget_giveback_request().
While unlocked, the completion callback or a concurrent r8a66597_dequeue()
can empty ep->queue while ep->ep.desc remains set, causing
get_request_from_ep() to pass a bogus pointer to start_packet().
Recheck !list_empty(&ep->queue) after reacquiring ep->r8a66597->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/r8a66597-udc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c
index 469075b06..9e65a5dd9 100644
--- a/drivers/usb/gadget/udc/r8a66597-udc.c
+++ b/drivers/usb/gadget/udc/r8a66597-udc.c
@@ -925,7 +925,7 @@ __acquires(r8a66597->lock)
usb_gadget_giveback_request(&ep->ep, &req->req);
spin_lock(&ep->r8a66597->lock);
- if (restart) {
+ if (restart && !list_empty(&ep->queue)) {
req = get_request_from_ep(ep);
if (ep->ep.desc)
start_packet(ep, req);
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 2/2] usb: gadget: r8a66597-udc: recheck ep->queue after reacquiring lock
2026-11-30 10:34 ` [PATCH 2/2] usb: gadget: r8a66597-udc: " Ziheng Wei
@ 2026-11-30 10:40 ` sashiko-bot
0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-30 10:40 UTC (permalink / raw)
To: Ziheng Wei; +Cc: linux-usb
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] usb: gadget: r8a66597-udc: missing Fixes trailer for
transfer_complete() fix
--
commit 3db6fa5568a80723302de3c2c0e6ef4b095fb055
Author: Ziheng Wei <zihengw03@163.com>
> usb: gadget: r8a66597-udc: recheck ep->queue after reacquiring lock
>
> In transfer_complete(), restart is computed from !list_empty(&ep->queue)
> before dropping ep->r8a66597->lock for usb_gadget_giveback_request().
> While unlocked, the completion callback or a concurrent r8a66597_dequeue()
> can empty ep->queue while ep->ep.desc remains set, causing
> get_request_from_ep() to pass a bogus pointer to start_packet().
>
> Recheck !list_empty(&ep->queue) after reacquiring ep->r8a66597->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>
[Severity: Low]
Since this fixes a bug in transfer_complete() present since the driver was
added, should the commit message include a Fixes tag?
Fixes: c41442474a26 ("usb: gadget: R8A66597 peripheral controller support.")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130103438.1384118-1-zihengw03@163.com?part=2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] usb: gadget: m66592-udc: recheck ep->queue after reacquiring lock
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
@ 2026-11-30 10:46 ` sashiko-bot
1 sibling, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-30 10:46 UTC (permalink / raw)
To: Ziheng Wei; +Cc: linux-usb
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] usb: gadget: m66592-udc: missing Fixes trailer for
transfer_complete() fix
--
commit 40f941bfe13761b7a5dce12306fa96681696cfdf
Author: Ziheng Wei <zihengw03@163.com>
> usb: gadget: m66592-udc: recheck ep->queue after reacquiring lock
>
> 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>
[Severity: Low]
This fixes a bug in transfer_complete(). Should it include a Fixes: tag:
Fixes: 4cf2503c6801 ("USB: m66592-udc: peripheral controller driver for M66592")
or for the commit that added the unlock/relock around the completion
callback:
Fixes: 598f22e11bef ("USB: m66592-udc: fixes some problems")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130103438.1384118-1-zihengw03@163.com?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-30 10:46 UTC | newest]
Thread overview: 4+ 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
2026-11-30 10:40 ` sashiko-bot
2026-11-30 10:46 ` [PATCH 1/2] usb: gadget: m66592-udc: " sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox