Skip to content

Commit

Permalink
ASoC: SOF: Intel: hda-dai: fix potential locking issue
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Mark Brown <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
plbossart authored and tiwai committed Sep 28, 2021
1 parent 868ddfc commit a20f3b1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sound/soc/sof/intel/hda-dai.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit a20f3b1

Please sign in to comment.