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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6A0BC4321E for ; Wed, 24 Nov 2021 13:21:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244738AbhKXNYO (ORCPT ); Wed, 24 Nov 2021 08:24:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:39542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349264AbhKXNS5 (ORCPT ); Wed, 24 Nov 2021 08:18:57 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 68A3261261; Wed, 24 Nov 2021 12:46:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1637757966; bh=A8grbP04A6YB3RAO8z6CJcLZPEYRULMRDWYYr3pr1YM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Ef1BUkZlS5w92BQhH8xjH4+9iEcKp/dxlxoTxxdIxV3lZ/UDaGxbujsqXQq+cDMC m5v5VpFlf4CWNbc2K7aaV/XRJxiSDanHgTZZQkpmo5BpfhMvqfLnYPWjiFX0DxiuWQ At10QNPL51IOXG2pDnBzTC1eXTuC9b+sa1jBVb10= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pierre-Louis Bossart , Mark Brown , Takashi Iwai , Sasha Levin Subject: [PATCH 5.4 012/100] ASoC: SOF: Intel: hda-dai: fix potential locking issue Date: Wed, 24 Nov 2021 12:57:28 +0100 Message-Id: <20211124115655.244777597@linuxfoundation.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211124115654.849735859@linuxfoundation.org> References: <20211124115654.849735859@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@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 3f645200d3a5c..b3cdd10c83ae1 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -67,6 +67,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); @@ -106,12 +107,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