linux-stable/sound/firewire/tascam
Xu Biang 8456a96c6b ALSA: firewire-tascam: add missing unwind goto in snd_tscm_stream_start_duplex()
commit fb4a624f88 upstream.

Smatch Warns:
sound/firewire/tascam/tascam-stream.c:493 snd_tscm_stream_start_duplex()
warn: missing unwind goto?

The direct return will cause the stream list of "&tscm->domain" unemptied
and the session in "tscm" unfinished if amdtp_domain_start() returns with
an error.

Fix this by changing the direct return to a goto which will empty the
stream list of "&tscm->domain" and finish the session in "tscm".

The snd_tscm_stream_start_duplex() function is called in the prepare
callback of PCM. According to "ALSA Kernel API Documentation", the prepare
callback of PCM will be called many times at each setup. So, if the
"&d->streams" list is not emptied, when the prepare callback is called
next time, snd_tscm_stream_start_duplex() will receive -EBUSY from
amdtp_domain_add_stream() that tries to add an existing stream to the
domain. The error handling code after the "error" label will be executed
in this case, and the "&d->streams" list will be emptied. So not emptying
the "&d->streams" list will not cause an issue. But it is more efficient
and readable to empty it on the first error by changing the direct return
to a goto statement.

The session in "tscm" has been begun before amdtp_domain_start(), so it
needs to be finished when amdtp_domain_start() fails.

Fixes: c281d46a51 ("ALSA: firewire-tascam: support AMDTP domain")
Signed-off-by: Xu Biang <xubiang@hust.edu.cn>
Reviewed-by: Dan Carpenter <error27@gmail.com>
Acked-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20230406132801.105108-1-xubiang@hust.edu.cn
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-04-20 12:35:05 +02:00
..
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
amdtp-tascam.c ALSA: firewire-lib: add flag to unaware of syt in CIP header 2021-05-22 08:46:41 +02:00
tascam-hwdep.c ALSA: Convert strlcpy to strscpy when return value is unused 2021-01-08 09:30:05 +01:00
tascam-midi.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 345 2019-06-05 17:37:08 +02:00
tascam-pcm.c ALSA: firewire: Replace runtime->status->state reference to runtime->state 2022-09-27 08:47:25 +02:00
tascam-proc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 345 2019-06-05 17:37:08 +02:00
tascam-stream.c ALSA: firewire-tascam: add missing unwind goto in snd_tscm_stream_start_duplex() 2023-04-20 12:35:05 +02:00
tascam-transaction.c ALSA: firewire-tascam: Fix integer overflow in midi_port_work() 2021-01-12 14:57:38 +01:00
tascam.c ALSA: firewire-tascam: cease from delayed card registration 2021-06-07 17:14:36 +02:00
tascam.h ALSA: firewire-tascam: cease from delayed card registration 2021-06-07 17:14:36 +02:00