Commit a20f3b10 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Takashi Iwai
Browse files

ASoC: SOF: Intel: hda-dai: fix potential locking issue



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: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Acked-by: default avatarMark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210924192417.169243-5-pierre-louis.bossart@linux.intel.com


Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 868ddfce
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -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;
}