From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E51EFC7618D for ; Thu, 6 Apr 2023 14:48:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239050AbjDFOsh (ORCPT ); Thu, 6 Apr 2023 10:48:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236859AbjDFOsR (ORCPT ); Thu, 6 Apr 2023 10:48:17 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65DEDC64D for ; Thu, 6 Apr 2023 07:47:01 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 27C7622772; Thu, 6 Apr 2023 14:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1680792371; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Q+JX1s/KR0nLimx4PnuykLK94hvVsXNQegddVBLCKn0=; b=HcLEds76/mjYjp/fi8YZ9KsDCHNH3rbOuQP3DwpwFlLwuaOzcIl5Nw3OtjY3zPRUPkidKT G4g2IKgDY+qrIyQvkgv8ykFBWK3BY9VbYRCZUwHl8+i19II6f0x2kuxnQ/MctTuGuF1HSU 7pLxwn6pLmarAJ25PgQHrfFXG4QeHoQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1680792371; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Q+JX1s/KR0nLimx4PnuykLK94hvVsXNQegddVBLCKn0=; b=Oi2hUUEs2XZrd0GNzh+bStiV6/+LTlt3iYboBnIBfpJVL31jiJdTl+OWdV07i1FITQv330 eNvKSIJrk2NaBBCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id EC02A1351F; Thu, 6 Apr 2023 14:46:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id DXfTODLbLmQxNwAAMHmgww (envelope-from ); Thu, 06 Apr 2023 14:46:10 +0000 Date: Thu, 06 Apr 2023 16:46:10 +0200 Message-ID: <87a5zlt6fh.wl-tiwai@suse.de> From: Takashi Iwai To: Xu Biang Cc: Clemens Ladisch , Takashi Sakamoto , Jaroslav Kysela , Takashi Iwai , dzm91@hust.edu.cn, error27@gmail.com, hust-os-kernel-patches@googlegroups.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ALSA: firewire-tascam: add missing unwind goto in snd_tscm_stream_start_duplex() In-Reply-To: <20230406132801.105108-1-xubiang@hust.edu.cn> References: <20230406132801.105108-1-xubiang@hust.edu.cn> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 06 Apr 2023 15:28:01 +0200, Xu Biang wrote: > > 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 Thanks, applied now. Takashi