From nobody Wed Dec 17 04:00:30 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99D1AFA3740 for ; Mon, 24 Oct 2022 12:00:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232229AbiJXMAR (ORCPT ); Mon, 24 Oct 2022 08:00:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232396AbiJXL60 (ORCPT ); Mon, 24 Oct 2022 07:58:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2571760CA; Mon, 24 Oct 2022 04:47:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1F90361291; Mon, 24 Oct 2022 11:47:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3243CC433C1; Mon, 24 Oct 2022 11:47:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612051; bh=sM65ncKA0Fp2DSYemjydTSKTheS9f7SXxpox3tYAn2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jNqBN8ku60M9m9AqrE/vJ1Yo2Rr9q30ZqB++9ynbZORSWK/cGzyqvCEpZsq08yUb9 /48hb3t3FKRLKLCrpNBUw/VLxQ8F75k3C2bbwk6hOysiNWmLXNAyHphcduDzInkBuK GBu1WMWbA0dt+F3qi0QtZgXA5poMp8iHAtYpZWtU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 4.14 051/210] ALSA: rawmidi: Drop register_mutex in snd_rawmidi_free() Date: Mon, 24 Oct 2022 13:29:28 +0200 Message-Id: <20221024112958.649197190@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Takashi Iwai commit a70aef7982b012e86dfd39fbb235e76a21ae778a upstream. The register_mutex taken around the dev_unregister callback call in snd_rawmidi_free() may potentially lead to a mutex deadlock, when OSS emulation and a hot unplug are involved. Since the mutex doesn't protect the actual race (as the registration itself is already protected by another means), let's drop it. Link: https://lore.kernel.org/r/CAB7eexJP7w1B0mVgDF0dQ+gWor7UdkiwPczmL7pn91= xx8xpzOA@mail.gmail.com Cc: Link: https://lore.kernel.org/r/20221011070147.7611-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/core/rawmidi.c | 2 -- 1 file changed, 2 deletions(-) --- a/sound/core/rawmidi.c +++ b/sound/core/rawmidi.c @@ -1633,10 +1633,8 @@ static int snd_rawmidi_free(struct snd_r =20 snd_info_free_entry(rmidi->proc_entry); rmidi->proc_entry =3D NULL; - mutex_lock(®ister_mutex); if (rmidi->ops && rmidi->ops->dev_unregister) rmidi->ops->dev_unregister(rmidi); - mutex_unlock(®ister_mutex); =20 snd_rawmidi_free_substreams(&rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT]); snd_rawmidi_free_substreams(&rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT]);