ASoC: ABE: Protect playback/capture triggers against removal

Playback/capture triggers iterate over BE clients which can change
dynamically if audio routes change. Use list_for_each_entry_safe
to protect triggers against BE clients removal.

Change-Id: I25f66a33f11863d0e149d09971f02b5ab75754b4
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
diff --git a/sound/soc/omap/omap-abe.c b/sound/soc/omap/omap-abe.c
index 46c907e..049f8b6 100644
--- a/sound/soc/omap/omap-abe.c
+++ b/sound/soc/omap/omap-abe.c
@@ -554,7 +554,7 @@
 		struct snd_soc_dai *dai, int cmd)
 {
 	struct snd_soc_pcm_runtime *fe = substream->private_data;
-	struct snd_soc_dsp_params *dsp_params;
+	struct snd_soc_dsp_params *dsp_params, *tmp;
 	struct snd_pcm_substream *be_substream;
 	int stream = substream->stream;
 
@@ -564,7 +564,7 @@
 	case SNDRV_PCM_TRIGGER_START:
 
 		/* mute and enable BE ports */
-		list_for_each_entry(dsp_params, &fe->dsp[stream].be_clients, list_be) {
+		list_for_each_entry_safe(dsp_params, tmp, &fe->dsp[stream].be_clients, list_be) {
 			struct snd_soc_pcm_runtime *be = dsp_params->be;
 
 			/* does this trigger() apply to this BE and stream ? */
@@ -629,7 +629,7 @@
 		}
 
 		/* disable BE ports */
-		list_for_each_entry(dsp_params, &fe->dsp[stream].be_clients, list_be) {
+		list_for_each_entry_safe(dsp_params, tmp, &fe->dsp[stream].be_clients, list_be) {
 			struct snd_soc_pcm_runtime *be = dsp_params->be;
 
 			/* does this trigger() apply to this BE and stream ? */
@@ -662,7 +662,7 @@
 		struct snd_soc_dai *dai, int cmd)
 {
 	struct snd_soc_pcm_runtime *fe = substream->private_data;
-	struct snd_soc_dsp_params *dsp_params;
+	struct snd_soc_dsp_params *dsp_params, *tmp;
 	struct snd_pcm_substream *be_substream;
 	int stream = substream->stream;
 
@@ -672,7 +672,7 @@
 	case SNDRV_PCM_TRIGGER_START:
 
 		/* mute and enable ports */
-		list_for_each_entry(dsp_params, &fe->dsp[stream].be_clients, list_be) {
+		list_for_each_entry_safe(dsp_params, tmp, &fe->dsp[stream].be_clients, list_be) {
 			struct snd_soc_pcm_runtime *be = dsp_params->be;
 
 			/* does this trigger() apply to the FE ? */
@@ -742,7 +742,7 @@
 		}
 
 		/* disable BE ports */
-		list_for_each_entry(dsp_params, &fe->dsp[stream].be_clients, list_be) {
+		list_for_each_entry_safe(dsp_params, tmp, &fe->dsp[stream].be_clients, list_be) {
 			struct snd_soc_pcm_runtime *be = dsp_params->be;
 
 			/* does this trigger() apply to this BE and stream ? */