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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4088CC76196 for ; Thu, 6 Apr 2023 14:47:33 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 06208EE6; Thu, 6 Apr 2023 16:46:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 06208EE6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1680792451; bh=Qlo8OM1F8QpA3C1H5flBe6xebzZG9G7/GuGvHEdSo14=; h=Date:From:To:Subject:In-Reply-To:References:CC:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=hCkpbOwY0X7Jm36grbnJg2p0Oo/xDRHVNtM8t8yi1cO/jNUfhaSshTTpDzCERFGeC p6tQ0z8IrQG3/wQAA0oVCqiW7UDImlT9I5hoNujeA/JPS7+fCyoeXzwwx9CBQfCUZ5 whrCxtT0x9pvFbW+m4ndW8LaoYrGgRmAvGhVg4qA= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 07EDFF80246; Thu, 6 Apr 2023 16:46:19 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 34DC5F80246; Thu, 6 Apr 2023 16:46:15 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CE43BF80149 for ; Thu, 6 Apr 2023 16:46:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CE43BF80149 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=HcLEds76; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Oi2hUUEs 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 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 Message-ID-Hash: JQ3Z7IKFDJXKSQUVD3ZQKPL3AULTHQ6I X-Message-ID-Hash: JQ3Z7IKFDJXKSQUVD3ZQKPL3AULTHQ6I X-MailFrom: tiwai@suse.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Clemens Ladisch , 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 X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 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