From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48DB4CA9EA0 for ; Mon, 4 Nov 2019 10:42:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1FB53222C2 for ; Mon, 4 Nov 2019 10:42:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726526AbfKDKmQ (ORCPT ); Mon, 4 Nov 2019 05:42:16 -0500 Received: from mx2.suse.de ([195.135.220.15]:44324 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728413AbfKDKmQ (ORCPT ); Mon, 4 Nov 2019 05:42:16 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6B28EB1D2; Mon, 4 Nov 2019 10:42:14 +0000 (UTC) Date: Mon, 04 Nov 2019 11:42:14 +0100 Message-ID: From: Takashi Iwai To: Sasha Levin 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 In-Reply-To: <20191104103020.GB4787@sasha-vm> References: <1572802859163107@kroah.com> <20191104103020.GB4787@sasha-vm> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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 . > > > >thanks, > > > >greg k-h > > > >------------------ original commit in Linus's tree ------------------ > > > >From a39331867335d4a94b6165e306265c9e24aca073 Mon Sep 17 00:00:00 2001 > >From: Takashi Iwai > >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 > >Cc: > >Signed-off-by: Takashi Iwai > > 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