public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Michal Pecio <michal.pecio@gmail.com>
To: Ginger <ginger.jzllee@gmail.com>
Cc: b-liu@ti.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [bug report] Potential deadlock bug in 'drivers/usb/musb/musb_core.c', between 'musb_g_giveback()' and 'musb_stage0_irq()'
Date: Sat, 25 Apr 2026 10:27:56 +0200	[thread overview]
Message-ID: <20260425102756.3340851e.michal.pecio@gmail.com> (raw)
In-Reply-To: <CAGp+u1YAUsw=qCMky=mM__mchVEP=e=S3WgVk_A87FLXwpm9vQ@mail.gmail.com>

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

      reply	other threads:[~2026-04-25  8:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260425102756.3340851e.michal.pecio@gmail.com \
    --to=michal.pecio@gmail.com \
    --cc=b-liu@ti.com \
    --cc=ginger.jzllee@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox