Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2662834pxa; Mon, 17 Aug 2020 15:54:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpUdsFC/JwiXCyl6GsUAitVnbhcf/WgG7XZXSy0fGwXcY/UaKqnmgOgvdhaJKL0ED31baR X-Received: by 2002:a17:906:f8d9:: with SMTP id lh25mr18209523ejb.458.1597704860138; Mon, 17 Aug 2020 15:54:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597704860; cv=none; d=google.com; s=arc-20160816; b=UV3RbYq8hzAzH8fM02ln3x6a349GgiQUEHvpDrhZErL9Srn1DtL2MraSxMwF11Ne5/ WHT0t3IN8NpQOJLxpjIIhqEkj0QxSdNxrVh7L+rL0R2lzz4vt7DVhlm+CN4ae60ro6ZZ ZeH8EeON7bA1zkG5fXfB+joDqJZY3xat/7Lz60+ANNsqbna+ux0So91bfopXEHi3vQbG U+XkH4iNrQW0oyJumBV70Cm+ypWwZ+1fGHzqIcGUJ3qNImtSp6nlJ51V2syC2Tdo68BO fn+7+bUMUR7jIKKmFFjmYRhWIyqFKgzWouYiXT30HuyjMpE+lPSDoXeP45B5tPnCGay4 0lyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yagUTdEFa74tcfYjNyf6Eh2VtauwiiuqaozPycaPWMc=; b=lmckLtx8Ni+EFV3Wso3mQhe4dkdkrSDCVdpJV8veB6wqCaGttYcDo62QhXppSKjq9M mV1HvMe8zxTbEX+mkfAAoNx43eh7hQSiM0uh1/PZJZ637er7qe6SyMNU4+SPUWtWr48g 7cGaWYCS+tLxHFPjMKfTijjIwW405qMwD7LpeT83b1dqkNSfbClAcVmw26Nt8L4z5uHI Q4U1fpCxh0rpnGD0BG8Q1yiWGD380ZLJnB0FUkVupCk3/rNmoay29PkXCczJFu/rS6oh D9LNK6WD4v1tP22TFdzUd4bh2cRXxiG5A/XA78KId3H77NR5egxJj/wcYDx7eGWcDlw+ bvJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TGb1Vo3c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cz6si12918231edb.188.2020.08.17.15.53.56; Mon, 17 Aug 2020 15:54:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TGb1Vo3c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404215AbgHQTdB (ORCPT + 99 others); Mon, 17 Aug 2020 15:33:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:55656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730281AbgHQPb1 (ORCPT ); Mon, 17 Aug 2020 11:31:27 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 265A922BEA; Mon, 17 Aug 2020 15:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678286; bh=5g143PedhAMhKBn4Ao3RmJSWsNaby5hpi/DdzB/TTXc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TGb1Vo3ccD5zRLfPlJ2BOKfy1uD2OiGKyXA1DUIGCenlsq0YFqhdM9yatok7Bs9uX VL8i5SVNrseLFs/MVUNXPjZd+5rP5ddpSHB3ZSIGnAmSVJF+GDzLjWQdc4c2irKOdc upOZes3km7VVl1hJA9HG8+7IlRjO7GiM8JXhj50A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kai Vehmanen , Pierre-Louis Bossart , Rander Wang , Mark Brown , Sasha Levin Subject: [PATCH 5.8 280/464] ASoC: hdac_hda: fix deadlock after PCM open error Date: Mon, 17 Aug 2020 17:13:53 +0200 Message-Id: <20200817143847.170180769@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kai Vehmanen [ Upstream commit 06f07e2365378d51eddd0b5bf23506e1237662b0 ] Commit 5bd70440cb0a ("ASoC: soc-dai: revert all changes to DAI startup/shutdown sequence"), introduced a slight change of semantics to DAI startup/shutdown. If startup() returns an error, shutdown() is now called for the DAI. This causes a deadlock in hdac_hda which issues a call to snd_hda_codec_pcm_put() in case open fails. Upon error, soc_pcm_open() will call shutdown(), and pcm_put() ends up getting called twice. Result is a deadlock on pcm->open_mutex, as snd_device_free() gets called from within snd_pcm_open(). Typical task backtrace looks like this: [ 334.244627] snd_pcm_dev_disconnect+0x49/0x340 [snd_pcm] [ 334.244634] __snd_device_disconnect.part.0+0x2c/0x50 [snd] [ 334.244640] __snd_device_free+0x7f/0xc0 [snd] [ 334.244650] snd_hda_codec_pcm_put+0x87/0x120 [snd_hda_codec] [ 334.244660] soc_pcm_open+0x6a0/0xbe0 [snd_soc_core] [ 334.244676] ? dpcm_add_paths.isra.0+0x491/0x590 [snd_soc_core] [ 334.244679] ? kfree+0x9a/0x230 [ 334.244686] dpcm_be_dai_startup+0x255/0x300 [snd_soc_core] [ 334.244695] dpcm_fe_dai_open+0x20e/0xf30 [snd_soc_core] [ 334.244701] ? snd_pcm_hw_rule_muldivk+0x110/0x110 [snd_pcm] [ 334.244709] ? dpcm_be_dai_startup+0x300/0x300 [snd_soc_core] [ 334.244714] ? snd_pcm_attach_substream+0x3c4/0x540 [snd_pcm] [ 334.244719] snd_pcm_open_substream+0x69a/0xb60 [snd_pcm] [ 334.244729] ? snd_pcm_release_substream+0x30/0x30 [snd_pcm] [ 334.244732] ? __mutex_lock_slowpath+0x10/0x10 [ 334.244736] snd_pcm_open+0x1b3/0x3c0 [snd_pcm] Fixes: 5bd70440cb0a ("ASoC: soc-dai: revert all changes to DAI startup/shutdown sequence") Signed-off-by: Kai Vehmanen Reviewed-by: Pierre-Louis Bossart Reviewed-by: Rander Wang BugLink: https://github.com/thesofproject/linux/issues/2159 Link: https://lore.kernel.org/r/20200717101950.3885187-3-kai.vehmanen@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/hdac_hda.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/sound/soc/codecs/hdac_hda.c b/sound/soc/codecs/hdac_hda.c index 473efe9ef998a..b0370bb10c142 100644 --- a/sound/soc/codecs/hdac_hda.c +++ b/sound/soc/codecs/hdac_hda.c @@ -289,7 +289,6 @@ static int hdac_hda_dai_open(struct snd_pcm_substream *substream, struct hdac_hda_priv *hda_pvt; struct hda_pcm_stream *hda_stream; struct hda_pcm *pcm; - int ret; hda_pvt = snd_soc_component_get_drvdata(component); pcm = snd_soc_find_pcm_from_dai(hda_pvt, dai); @@ -300,11 +299,7 @@ static int hdac_hda_dai_open(struct snd_pcm_substream *substream, hda_stream = &pcm->stream[substream->stream]; - ret = hda_stream->ops.open(hda_stream, &hda_pvt->codec, substream); - if (ret < 0) - snd_hda_codec_pcm_put(pcm); - - return ret; + return hda_stream->ops.open(hda_stream, &hda_pvt->codec, substream); } static void hdac_hda_dai_close(struct snd_pcm_substream *substream, -- 2.25.1