Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Sasha Levin <sashal@kernel.org>
Cc: gregkh@linuxfoundation.org, kirill.shutemov@linux.intel.com,
	stable@vger.kernel.org
Subject: Re: FAILED: patch "[PATCH] ALSA: timer: Fix mutex deadlock at releasing card" failed to apply to 4.19-stable tree
Date: Mon, 04 Nov 2019 11:42:14 +0100	[thread overview]
Message-ID: <s5hmudbx6rd.wl-tiwai@suse.de> (raw)
In-Reply-To: <20191104103020.GB4787@sasha-vm>

On Mon, 04 Nov 2019 11:30:20 +0100,
Sasha Levin wrote:
> 
> On Sun, Nov 03, 2019 at 06:40:59PM +0100, gregkh@linuxfoundation.org wrote:
> >
> >The patch below does not apply to the 4.19-stable tree.
> >If someone wants it applied there, or to any other stable or longterm
> >tree, then please email the backport, including the original git commit
> >id to <stable@vger.kernel.org>.
> >
> >thanks,
> >
> >greg k-h
> >
> >------------------ original commit in Linus's tree ------------------
> >
> >From a39331867335d4a94b6165e306265c9e24aca073 Mon Sep 17 00:00:00 2001
> >From: Takashi Iwai <tiwai@suse.de>
> >Date: Wed, 30 Oct 2019 22:42:57 +0100
> >Subject: [PATCH] ALSA: timer: Fix mutex deadlock at releasing card
> >
> >When a card is disconnected while in use, the system waits until all
> >opened files are closed then releases the card.  This is done via
> >put_device() of the card device in each device release code.
> >
> >The recently reported mutex deadlock bug happens in this code path;
> >snd_timer_close() for the timer device deals with the global
> >register_mutex and it calls put_device() there.  When this timer
> >device is the last one, the card gets freed and it eventually calls
> >snd_timer_free(), which has again the protection with the global
> >register_mutex -- boom.
> >
> >Basically put_device() call itself is race-free, so a relative simple
> >workaround is to move this put_device() call out of the mutex.  For
> >achieving that, in this patch, snd_timer_close_locked() got a new
> >argument to store the card device pointer in return, and each caller
> >invokes put_device() with the returned object after the mutex unlock.
> >
> >Reported-and-tested-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> >Cc: <stable@vger.kernel.org>
> >Signed-off-by: Takashi Iwai <tiwai@suse.de>
> 
> Looks like this was introduced by 41672c0c24a6 ("ALSA: timer: Simplify
> error path in snd_timer_open()"), which means it's not needed on 4.19 or
> older.

We'd still need a similar fix, as the code path in question is about
closing, not opening the device.  If backporting the commit
41672c0c24a6 makes the fix cleanly applicable, it'd be worth to
backport both.

If not, I can submit a modified 4.19.y patch, too.


thanks,

Takashi

  reply	other threads:[~2019-11-04 10:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-03 17:40 FAILED: patch "[PATCH] ALSA: timer: Fix mutex deadlock at releasing card" failed to apply to 4.19-stable tree gregkh
2019-11-04 10:30 ` Sasha Levin
2019-11-04 10:42   ` Takashi Iwai [this message]
2019-11-04 12:25     ` Sasha Levin
2019-11-04 13:20       ` Takashi Iwai

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=s5hmudbx6rd.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=sashal@kernel.org \
    --cc=stable@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