Skip to content

Commit fb4a624

Browse files
BIIIANGtiwai
authored andcommitted
ALSA: firewire-tascam: add missing unwind goto in snd_tscm_stream_start_duplex()
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: c281d46 ("ALSA: firewire-tascam: support AMDTP domain") Signed-off-by: Xu Biang <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Acked-by: Takashi Sakamoto <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 8dd1321 commit fb4a624

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sound/firewire/tascam/tascam-stream.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ int snd_tscm_stream_start_duplex(struct snd_tscm *tscm, unsigned int rate)
490490
// packet is important for media clock recovery.
491491
err = amdtp_domain_start(&tscm->domain, tx_init_skip_cycles, true, true);
492492
if (err < 0)
493-
return err;
493+
goto error;
494494

495495
if (!amdtp_domain_wait_ready(&tscm->domain, READY_TIMEOUT_MS)) {
496496
err = -ETIMEDOUT;

0 commit comments

Comments
 (0)