* [bug report] Potential deadlock bug in 'drivers/usb/musb/musb_core.c', between 'musb_g_giveback()' and 'musb_stage0_irq()'
@ 2026-04-24 4:50 Ginger
2026-04-25 8:27 ` Michal Pecio
0 siblings, 1 reply; 2+ messages in thread
From: Ginger @ 2026-04-24 4:50 UTC (permalink / raw)
To: b-liu; +Cc: linux-usb, linux-kernel
Dear Linux kernel maintainers,
My research-based static analyzer found a potential deadlock bug
within the 'drivers/usb/musb' subsystem, more specifically, in
'drivers/usb/musb/musb_core.c'.
This deadlock potentially occurs with the involvement of hard irq.
Kernel version: long-term kernel v6.18.9
Potential concurrent triggering executions:
T0:
musb_stage0_irq [t1]
--> musb_handle_intr_resume
--> musb_g_resume
--> spin_lock(&musb->lock); [t2]
T1:
musb_g_giveback
--> spin_lock(&musb->lock); [t0]
If T0 (i.e., the hard irq) occurs after T1 acquires the lock and both
happen within the same CPU, then T0 will not proceed because it cannot
hold the spin lock that has already been possessed by T1, yet T1
cannot proceed because the hard irq runs disables preempts.
Simply speaking, t0 -> t1 -> t2 can lead to a deadlock.
Thank you for your time and consideration.
Best regards,
Ginger
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] Potential deadlock bug in 'drivers/usb/musb/musb_core.c', between 'musb_g_giveback()' and 'musb_stage0_irq()'
2026-04-24 4:50 [bug report] Potential deadlock bug in 'drivers/usb/musb/musb_core.c', between 'musb_g_giveback()' and 'musb_stage0_irq()' Ginger
@ 2026-04-25 8:27 ` Michal Pecio
0 siblings, 0 replies; 2+ messages in thread
From: Michal Pecio @ 2026-04-25 8:27 UTC (permalink / raw)
To: Ginger; +Cc: b-liu, linux-usb, linux-kernel
On Fri, 24 Apr 2026 12:50:43 +0800, Ginger wrote:
> Dear Linux kernel maintainers,
>
> My research-based static analyzer found a potential deadlock bug
> within the 'drivers/usb/musb' subsystem, more specifically, in
> 'drivers/usb/musb/musb_core.c'.
> This deadlock potentially occurs with the involvement of hard irq.
>
> Kernel version: long-term kernel v6.18.9
>
> Potential concurrent triggering executions:
> T0:
> musb_stage0_irq [t1]
> --> musb_handle_intr_resume
> --> musb_g_resume
> --> spin_lock(&musb->lock); [t2]
>
> T1:
> musb_g_giveback
> --> spin_lock(&musb->lock); [t0]
>
> If T0 (i.e., the hard irq) occurs after T1 acquires the lock and both
> happen within the same CPU, then T0 will not proceed because it cannot
> hold the spin lock that has already been possessed by T1, yet T1
> cannot proceed because the hard irq runs disables preempts.
> Simply speaking, t0 -> t1 -> t2 can lead to a deadlock.
Hi,
You may want to consider earlier operations on the same lock and their
implications. This function releases musb->lock before acquiring it.
If called with the lock unlocked, that's a different kind of bug.
If called with IRQs enabled, the caller created this problem.
If called with IRQs disabled, it won't enable IRQs and won't deadlock.
Regards,
Michal
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-25 8:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-24 4:50 [bug report] Potential deadlock bug in 'drivers/usb/musb/musb_core.c', between 'musb_g_giveback()' and 'musb_stage0_irq()' Ginger
2026-04-25 8:27 ` Michal Pecio
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox