Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ASoC: samsung: i2s: release the runtime PM reference if config_setup fails
@ 2026-11-04  2:40 Wentao Liang
  2026-11-04  2:55 ` sashiko-bot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Wentao Liang @ 2026-11-04  2:40 UTC (permalink / raw)
  To: Sylwester Nawrocki, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai
  Cc: linux-sound

i2s_trigger() takes a runtime PM reference before calling config_setup().
config_setup() can fail with -EINVAL or -EAGAIN, and the error path
currently returns with that reference still held. A failed START does not
guarantee a matching STOP, so the runtime PM usage count stays elevated.

Drop the reference before returning the error.

Fixes: dc938ddb5628 ("ASoC: samsung: i2s: Ensure proper runtime PM state of I2S device")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 sound/soc/samsung/i2s.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
index 442e70b107da..d2060c3ff6e8 100644
--- a/sound/soc/samsung/i2s.c
+++ b/sound/soc/samsung/i2s.c
@@ -924,6 +924,7 @@ static int i2s_trigger(struct snd_pcm_substream *substream,
 	int capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE);
 	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
 	struct i2s_dai *i2s = to_info(snd_soc_rtd_to_cpu(rtd, 0));
+	bool failed = false;
 
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
@@ -935,8 +936,10 @@ static int i2s_trigger(struct snd_pcm_substream *substream,
 			priv->fixup_early(substream, dai);
 
 		scoped_guard(spinlock_irqsave, &priv->lock) {
-			if (config_setup(i2s))
-				return -EINVAL;
+			if (config_setup(i2s)) {
+				failed = true;
+				break;
+			}
 
 			if (priv->fixup_late)
 				priv->fixup_late(substream, dai);
@@ -946,6 +949,11 @@ static int i2s_trigger(struct snd_pcm_substream *substream,
 			else
 				i2s_txctrl(i2s, 1);
 		}
+
+		if (failed) {
+			pm_runtime_put(dai->dev);
+			return -EINVAL;
+		}
 		break;
 	case SNDRV_PCM_TRIGGER_STOP:
 	case SNDRV_PCM_TRIGGER_SUSPEND:
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-07 16:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04  2:40 [PATCH] ASoC: samsung: i2s: release the runtime PM reference if config_setup fails Wentao Liang
2026-11-04  2:55 ` sashiko-bot
2026-11-04  7:10 ` Krzysztof Kozlowski
2026-11-07 16:22 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox