Skip to contentSkip to conversation

ASoC: core: Do not cleanup uninitialized dais on soc_pcm_open failure

RFC PATCH Superseded Cezary Rojewski 4 participants 5 messages Sep 4, 2020 – Sep 7, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 ASoC: core: Do not cleanup uninitialized dais on soc_pcm_open failure

Introduce for_each_rtd_dais_rollback macro which behaves exactly like for_each_codec_dais_rollback and its cpu_dais equivalent but for all dais instead.

Use newly added macro to fix soc_pcm_open error path and prevent uninitialized dais from being cleaned-up.

---
 include/sound/soc.h | 2 ++
 sound/soc/soc-pcm.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
include/sound/soc.h +2 -0
index b94ebff12350..09a7d8409ade 100644
@@ -1193,6 +1193,8 @@ struct snd_soc_pcm_runtime {
 	     ((i) < (rtd)->num_cpus + (rtd)->num_codecs) &&		\
 		     ((dai) = (rtd)->dais[i]);				\
 	     (i)++)
+#define for_each_rtd_dais_rollback(rtd, i, dai)		\
+	for (; (--(i) >= 0) && ((dai) = (rtd)->dais[i]);)
 
 void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd);
 
sound/soc/soc-pcm.c +1 -1
index 00ac1cbf6f88..4c9d4cd8cf0b 100644
@@ -812,7 +812,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
 	return 0;
 
 config_err:
-	for_each_rtd_dais(rtd, i, dai)
+	for_each_rtd_dais_rollback(rtd, i, dai)
 		snd_soc_dai_shutdown(dai, substream);
 
 	snd_soc_link_shutdown(substream);
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Cezary Rojewski

Introduce for_each_rtd_dais_rollback macro which behaves exactly like

for_each_codec_dais_rollback and its cpu_dais equivalent but for all

dais instead.

Quoted 7 lines

Use newly added macro to fix soc_pcm_open error path and prevent

uninitialized dais from being cleaned-up.

Acked-by on v1 1/1
#2 lore raw
In reply to Cezary Rojewski

Hi Cezary

Quoted 9 lines

Introduce for_each_rtd_dais_rollback macro which behaves exactly like for_each_codec_dais_rollback and its cpu_dais equivalent but for all dais instead.

Use newly added macro to fix soc_pcm_open error path and prevent uninitialized dais from being cleaned-up.

---

Thank you for your patch

Thank you for your help !!

Best regards
---
Kuninori Morimoto

#3 lore raw
In reply to Cezary Rojewski
Quoted 7 lines · Cezary Rojewski

Introduce for_each_rtd_dais_rollback macro which behaves exactly like for_each_codec_dais_rollback and its cpu_dais equivalent but for all dais instead.

Use newly added macro to fix soc_pcm_open error path and prevent uninitialized dais from being cleaned-up.

Mark, may I re-send this patch with a quick update - append 'Fixes' and remove '[RFC]' tags - before this gets merged? Change would fill complete with these updates.

Czarek

maintainer
#4 lore raw
Quoted 3 lines · Cezary Rojewski

Mark, may I re-send this patch with a quick update - append 'Fixes' and remove '[RFC]' tags - before this gets merged? Change would fill complete with these updates.

Sure. For something like this it's better to just go ahead and do the resend whatever, worst case it'll get ignored best case less waiting.