From 87be64566e3b12d3cb99080e2fc9df29d5d5579f Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Apr 20 2023 11:00:06 +0000 Subject: ALSA: firewire-tascam: add missing unwind goto in snd_tscm_stream_start_duplex() (bsc#1012628). --- diff --git a/patches.kernel.org/6.2.12-009-ALSA-firewire-tascam-add-missing-unwind-goto-i.patch b/patches.kernel.org/6.2.12-009-ALSA-firewire-tascam-add-missing-unwind-goto-i.patch new file mode 100644 index 0000000..bbe7473 --- /dev/null +++ b/patches.kernel.org/6.2.12-009-ALSA-firewire-tascam-add-missing-unwind-goto-i.patch @@ -0,0 +1,65 @@ +From: Xu Biang +Date: Thu, 6 Apr 2023 06:28:01 -0700 +Subject: [PATCH] ALSA: firewire-tascam: add missing unwind goto in + snd_tscm_stream_start_duplex() +References: bsc#1012628 +Patch-mainline: 6.2.12 +Git-commit: fb4a624f88f658c7b7ae124452bd42eaa8ac7168 + +commit fb4a624f88f658c7b7ae124452bd42eaa8ac7168 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: c281d46a51e3 ("ALSA: firewire-tascam: support AMDTP domain") +Signed-off-by: Xu Biang +Reviewed-by: Dan Carpenter +Acked-by: Takashi Sakamoto +Cc: +Link: https://lore.kernel.org/r/20230406132801.105108-1-xubiang@hust.edu.cn +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Jiri Slaby +--- + sound/firewire/tascam/tascam-stream.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sound/firewire/tascam/tascam-stream.c b/sound/firewire/tascam/tascam-stream.c +index 53e094cc..dfe783d0 100644 +--- a/sound/firewire/tascam/tascam-stream.c ++++ b/sound/firewire/tascam/tascam-stream.c +@@ -490,7 +490,7 @@ int snd_tscm_stream_start_duplex(struct snd_tscm *tscm, unsigned int rate) + // packet is important for media clock recovery. + err = amdtp_domain_start(&tscm->domain, tx_init_skip_cycles, true, true); + if (err < 0) +- return err; ++ goto error; + + if (!amdtp_domain_wait_ready(&tscm->domain, READY_TIMEOUT_MS)) { + err = -ETIMEDOUT; +-- +2.35.3 + diff --git a/series.conf b/series.conf index efec241..bb0a985 100644 --- a/series.conf +++ b/series.conf @@ -2236,6 +2236,7 @@ patches.kernel.org/6.2.12-006-ALSA-i2c-cs8427-fix-iec958-mixer-control-deact.patch patches.kernel.org/6.2.12-007-ALSA-hda-patch_realtek-add-quirk-for-Asus-N760.patch patches.kernel.org/6.2.12-008-ALSA-hda-realtek-Add-quirks-for-Lenovo-Z13-Z16.patch + patches.kernel.org/6.2.12-009-ALSA-firewire-tascam-add-missing-unwind-goto-i.patch ######################################################## # Build fixes that apply to the vanilla kernel too.