All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Chengfeng Ye <dg573847474@gmail.com>
Cc: perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: sb: fix potential deadlock on &chip->mixer_lock
Date: Tue, 27 Jun 2023 12:01:29 +0200	[thread overview]
Message-ID: <87jzvpfcli.wl-tiwai@suse.de> (raw)
In-Reply-To: <20230627095616.5333-1-dg573847474@gmail.com>

On Tue, 27 Jun 2023 11:56:16 +0200,
Chengfeng Ye wrote:
> 
> As &chip->mixer_lock is also acquired by the irq snd_sb8dsp_interrupt()
> which executes under hard-irq context, code executing under process
> context should disable irq before acquiring the lock, otherwise
> deadlock could happen if the process context hold the lock then
> preempt by the interruption.
> 
> As the ALSA Driver document described, PCM prepare callbacks are not
> executed with irq disabled by default, thus the acquiring of
> &chip->mixer_lock should be irq disabled.
> 
> Possible deadlock scenario:
> snd_sb8_playback_prepare
>     -> spin_lock(&chip->mixer_lock);
>         <irq interrupt>
>         -> snd_sb8dsp_interrupt()
>         -> snd_sb8_capture_trigger()
>         -> spin_lock(&chip->mixer_lock); (deadlock here)
> 
> This flaw was found using an experimental static analysis tool we are
> developing for irq-related deadlock.
> 
> The tentative patch fix the potential deadlock by spin_lock_irqsave().
> 
> Signed-off-by: Chengfeng Ye <dg573847474@gmail.com>

I believe it's a false-positive.  There is already a call
	spin_lock_irqsave(&chip->reg_lock, flags);
beforehand.


thanks,

Takashi

  reply	other threads:[~2023-06-27 10:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27  9:56 [PATCH] ALSA: sb: fix potential deadlock on &chip->mixer_lock Chengfeng Ye
2023-06-27 10:01 ` Takashi Iwai [this message]
2023-06-27 10:55   ` 叶澄锋

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=87jzvpfcli.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=dg573847474@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.