]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
ASoC: SOF: Intel: hda-dai: fix potential locking issue
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Fri, 24 Sep 2021 19:24:17 +0000 (14:24 -0500)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Thu, 13 Jan 2022 17:42:52 +0000 (18:42 +0100)
BugLink: https://bugs.launchpad.net/bugs/1954834
[ 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 <pierre-louis.bossart@linux.intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210924192417.169243-5-pierre-louis.bossart@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
sound/soc/sof/intel/hda-dai.c

index 3f645200d3a5cc1eb93ee94ecc07544dbec6c9f2..b3cdd10c83ae1a59d9a5eaabd8ac43ff82287c86 100644 (file)
@@ -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;
 }