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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1E53C433EF for ; Tue, 9 Nov 2021 22:19:05 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C42E7617E5 for ; Tue, 9 Nov 2021 22:19:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C42E7617E5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2D53411C; Tue, 9 Nov 2021 23:18:13 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2D53411C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1636496343; bh=3JAE28fSKA6qnrcEMQx9bPFgXNxbVen5lGwA92srAMo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=azfth+63Z1o0jd2Gyi5Q5eHzF98DnC0BaU4hBSsF9PwppKpLeukyhSgoxR/UtD7dy KzXDefXNqU+VHdfsW3fzRDWVbMLNP1mJfRdXVN/7dBq7nSW9OZHuVIRZGZoxTDFd2o 7AHIcsw5RV9z/JvJvEZW1aOb0yFVtYTHGL4fGxpI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C822EF804DA; Tue, 9 Nov 2021 23:18:03 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A3FADF804E0; Tue, 9 Nov 2021 23:18:02 +0100 (CET) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 98241F800C1 for ; Tue, 9 Nov 2021 23:17:56 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 98241F800C1 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oe5uDqn7" Received: by mail.kernel.org (Postfix) with ESMTPSA id 7258761279; Tue, 9 Nov 2021 22:17:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636496273; bh=3JAE28fSKA6qnrcEMQx9bPFgXNxbVen5lGwA92srAMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oe5uDqn7b10fYzTZ/oBDwNi5M6Zdf+yPnpbcfxVw4iR4S6xjW1leC4rNJP3F51Uzf DeDcBEUKotSRlyKLJsc75dqEgskuPBnslKaNdewcqN5+vwm2TwkLrOlA+4kVZI25IX 4RrZtWMLGcX3V1FGku4eX7ppt+sELTob8XGxH7UGbROh5EVzm/7sngNAjPzd2JaCeg BTk8yQpzOZVfcLZi97oyhTii7/t/GyMDDQPH9TiJzTH7Ti83AE+kENVAT03v+Wu1Xw bkKTzfT12jkSNtY1jBDsx+KuKBUUxwu0zGSl/luv0LQorWvsasIo7turxeKi8x/hOm mKCDj0HdH4o2g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 36/82] ASoC: SOF: Intel: hda-dai: fix potential locking issue Date: Tue, 9 Nov 2021 17:15:54 -0500 Message-Id: <20211109221641.1233217-36-sashal@kernel.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211109221641.1233217-1-sashal@kernel.org> References: <20211109221641.1233217-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Cc: Sasha Levin , alsa-devel@alsa-project.org, lgirdwood@gmail.com, Takashi Iwai , tiwai@suse.com, Pierre-Louis Bossart , Mark Brown X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Pierre-Louis Bossart [ Upstream commit a20f3b10de61add5e14b6ce4df982f4df2a4cbbc ] The initial hdac_stream code was adapted a third time with the same locking issues. Move the spin_lock outside the loops and make sure the fields are protected on read/write. Signed-off-by: Pierre-Louis Bossart Acked-by: Mark Brown Link: https://lore.kernel.org/r/20210924192417.169243-5-pierre-louis.bossart@linux.intel.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/soc/sof/intel/hda-dai.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index c1f9f0f584647..6704dbcd101cd 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -68,6 +68,7 @@ static struct hdac_ext_stream * return NULL; } + spin_lock_irq(&bus->reg_lock); list_for_each_entry(stream, &bus->stream_list, list) { struct hdac_ext_stream *hstream = stream_to_hdac_ext_stream(stream); @@ -107,12 +108,12 @@ static struct hdac_ext_stream * * is updated in snd_hdac_ext_stream_decouple(). */ if (!res->decoupled) - snd_hdac_ext_stream_decouple(bus, res, true); - spin_lock_irq(&bus->reg_lock); + snd_hdac_ext_stream_decouple_locked(bus, res, true); + res->link_locked = 1; res->link_substream = substream; - spin_unlock_irq(&bus->reg_lock); } + spin_unlock_irq(&bus->reg_lock); return res; } -- 2.33.0 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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE996C433EF for ; Tue, 9 Nov 2021 22:19:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A53B86108C for ; Tue, 9 Nov 2021 22:19:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245556AbhKIWWY (ORCPT ); Tue, 9 Nov 2021 17:22:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:41760 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245747AbhKIWUw (ORCPT ); Tue, 9 Nov 2021 17:20:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7258761279; Tue, 9 Nov 2021 22:17:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636496273; bh=3JAE28fSKA6qnrcEMQx9bPFgXNxbVen5lGwA92srAMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oe5uDqn7b10fYzTZ/oBDwNi5M6Zdf+yPnpbcfxVw4iR4S6xjW1leC4rNJP3F51Uzf DeDcBEUKotSRlyKLJsc75dqEgskuPBnslKaNdewcqN5+vwm2TwkLrOlA+4kVZI25IX 4RrZtWMLGcX3V1FGku4eX7ppt+sELTob8XGxH7UGbROh5EVzm/7sngNAjPzd2JaCeg BTk8yQpzOZVfcLZi97oyhTii7/t/GyMDDQPH9TiJzTH7Ti83AE+kENVAT03v+Wu1Xw bkKTzfT12jkSNtY1jBDsx+KuKBUUxwu0zGSl/luv0LQorWvsasIo7turxeKi8x/hOm mKCDj0HdH4o2g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pierre-Louis Bossart , Mark Brown , Takashi Iwai , Sasha Levin , lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org Subject: [PATCH AUTOSEL 5.15 36/82] ASoC: SOF: Intel: hda-dai: fix potential locking issue Date: Tue, 9 Nov 2021 17:15:54 -0500 Message-Id: <20211109221641.1233217-36-sashal@kernel.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211109221641.1233217-1-sashal@kernel.org> References: <20211109221641.1233217-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pierre-Louis Bossart [ Upstream commit a20f3b10de61add5e14b6ce4df982f4df2a4cbbc ] The initial hdac_stream code was adapted a third time with the same locking issues. Move the spin_lock outside the loops and make sure the fields are protected on read/write. Signed-off-by: Pierre-Louis Bossart Acked-by: Mark Brown Link: https://lore.kernel.org/r/20210924192417.169243-5-pierre-louis.bossart@linux.intel.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/soc/sof/intel/hda-dai.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index c1f9f0f584647..6704dbcd101cd 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -68,6 +68,7 @@ static struct hdac_ext_stream * return NULL; } + spin_lock_irq(&bus->reg_lock); list_for_each_entry(stream, &bus->stream_list, list) { struct hdac_ext_stream *hstream = stream_to_hdac_ext_stream(stream); @@ -107,12 +108,12 @@ static struct hdac_ext_stream * * is updated in snd_hdac_ext_stream_decouple(). */ if (!res->decoupled) - snd_hdac_ext_stream_decouple(bus, res, true); - spin_lock_irq(&bus->reg_lock); + snd_hdac_ext_stream_decouple_locked(bus, res, true); + res->link_locked = 1; res->link_substream = substream; - spin_unlock_irq(&bus->reg_lock); } + spin_unlock_irq(&bus->reg_lock); return res; } -- 2.33.0