Jiri Slaby 87be64
From: Xu Biang <xubiang@hust.edu.cn>
Jiri Slaby 87be64
Date: Thu, 6 Apr 2023 06:28:01 -0700
Jiri Slaby 87be64
Subject: [PATCH] ALSA: firewire-tascam: add missing unwind goto in
Jiri Slaby 87be64
 snd_tscm_stream_start_duplex()
Jiri Slaby 87be64
References: bsc#1012628
Jiri Slaby 87be64
Patch-mainline: 6.2.12
Jiri Slaby 87be64
Git-commit: fb4a624f88f658c7b7ae124452bd42eaa8ac7168
Jiri Slaby 87be64
Jiri Slaby 87be64
commit fb4a624f88f658c7b7ae124452bd42eaa8ac7168 upstream.
Jiri Slaby 87be64
Jiri Slaby 87be64
Smatch Warns:
Jiri Slaby 87be64
sound/firewire/tascam/tascam-stream.c:493 snd_tscm_stream_start_duplex()
Jiri Slaby 87be64
warn: missing unwind goto?
Jiri Slaby 87be64
Jiri Slaby 87be64
The direct return will cause the stream list of "&tscm->domain" unemptied
Jiri Slaby 87be64
and the session in "tscm" unfinished if amdtp_domain_start() returns with
Jiri Slaby 87be64
an error.
Jiri Slaby 87be64
Jiri Slaby 87be64
Fix this by changing the direct return to a goto which will empty the
Jiri Slaby 87be64
stream list of "&tscm->domain" and finish the session in "tscm".
Jiri Slaby 87be64
Jiri Slaby 87be64
The snd_tscm_stream_start_duplex() function is called in the prepare
Jiri Slaby 87be64
callback of PCM. According to "ALSA Kernel API Documentation", the prepare
Jiri Slaby 87be64
callback of PCM will be called many times at each setup. So, if the
Jiri Slaby 87be64
"&d->streams" list is not emptied, when the prepare callback is called
Jiri Slaby 87be64
next time, snd_tscm_stream_start_duplex() will receive -EBUSY from
Jiri Slaby 87be64
amdtp_domain_add_stream() that tries to add an existing stream to the
Jiri Slaby 87be64
domain. The error handling code after the "error" label will be executed
Jiri Slaby 87be64
in this case, and the "&d->streams" list will be emptied. So not emptying
Jiri Slaby 87be64
the "&d->streams" list will not cause an issue. But it is more efficient
Jiri Slaby 87be64
and readable to empty it on the first error by changing the direct return
Jiri Slaby 87be64
to a goto statement.
Jiri Slaby 87be64
Jiri Slaby 87be64
The session in "tscm" has been begun before amdtp_domain_start(), so it
Jiri Slaby 87be64
needs to be finished when amdtp_domain_start() fails.
Jiri Slaby 87be64
Jiri Slaby 87be64
Fixes: c281d46a51e3 ("ALSA: firewire-tascam: support AMDTP domain")
Jiri Slaby 87be64
Signed-off-by: Xu Biang <xubiang@hust.edu.cn>
Jiri Slaby 87be64
Reviewed-by: Dan Carpenter <error27@gmail.com>
Jiri Slaby 87be64
Acked-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Jiri Slaby 87be64
Cc: <stable@vger.kernel.org>
Jiri Slaby 87be64
Link: https://lore.kernel.org/r/20230406132801.105108-1-xubiang@hust.edu.cn
Jiri Slaby 87be64
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Jiri Slaby 87be64
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Jiri Slaby 87be64
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Jiri Slaby 87be64
---
Jiri Slaby 87be64
 sound/firewire/tascam/tascam-stream.c | 2 +-
Jiri Slaby 87be64
 1 file changed, 1 insertion(+), 1 deletion(-)
Jiri Slaby 87be64
Jiri Slaby 87be64
diff --git a/sound/firewire/tascam/tascam-stream.c b/sound/firewire/tascam/tascam-stream.c
Jiri Slaby 87be64
index 53e094cc..dfe783d0 100644
Jiri Slaby 87be64
--- a/sound/firewire/tascam/tascam-stream.c
Jiri Slaby 87be64
+++ b/sound/firewire/tascam/tascam-stream.c
Jiri Slaby 87be64
@@ -490,7 +490,7 @@ int snd_tscm_stream_start_duplex(struct snd_tscm *tscm, unsigned int rate)
Jiri Slaby 87be64
 		// packet is important for media clock recovery.
Jiri Slaby 87be64
 		err = amdtp_domain_start(&tscm->domain, tx_init_skip_cycles, true, true);
Jiri Slaby 87be64
 		if (err < 0)
Jiri Slaby 87be64
-			return err;
Jiri Slaby 87be64
+			goto error;
Jiri Slaby 87be64
 
Jiri Slaby 87be64
 		if (!amdtp_domain_wait_ready(&tscm->domain, READY_TIMEOUT_MS)) {
Jiri Slaby 87be64
 			err = -ETIMEDOUT;
Jiri Slaby 87be64
-- 
Jiri Slaby 87be64
2.35.3
Jiri Slaby 87be64