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 X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27B95C49EA7 for ; Thu, 24 Jun 2021 21:05:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0ECE6613C8 for ; Thu, 24 Jun 2021 21:05:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232515AbhFXVIR (ORCPT ); Thu, 24 Jun 2021 17:08:17 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:51385 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230116AbhFXVIP (ORCPT ); Thu, 24 Jun 2021 17:08:15 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 5B0645C00E5; Thu, 24 Jun 2021 17:05:55 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 24 Jun 2021 17:05:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=9jMAnkKABHSlUcjl0Zbwdrv+Qzw 4CH1IFEmMt+CBJQM=; b=nuN9S+LNn5VAyRaKqfsXBGPZxheCRq79sIDUlTillPD vaCbwLLzr9CuIQxNF7L6r8qv+BM8VEKVYJgZQzDw7gkzOu+rQ23FJ9yoJqj3Wy2o 6X7aetKdQkbvzSa6seVCvulVj/wr0b9zXETQ3SV06yBgVNaovOzY2AsZ1zAPSSTE RDn3hlVquDnOHoWk8cTDQVcqoegWnPr23JR06PAEL72Ur9Pv2/9X1qXD5sV/HPMD 0Y3vUZV1iLvibVyu45h6Ie9+RjbDa1cHYo71aKbdWRZ/u47SyqpXvtpbhXSrh7X2 re0rYiiI1AdONfxCO6gEQeM/6pHZ83pi82w1bMPQnGg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=9jMAnk KABHSlUcjl0Zbwdrv+Qzw4CH1IFEmMt+CBJQM=; b=f5ewB02t+PjuIZteLhi8Hq 1UV0AA+y4qceBWA7esCLDrt4V20nk7gGQp/Egihq9D0zc7rsIA5gWuNAk98mayz+ Waa9pdFcUQThjlfrTFHYr9kC4jUPNzNq3TrCODYqeIWROyD9tjVK5BniBVbdzeos XM/cFcgQ6QiXm4c62e3CHlUTKvYi7Tku0/jbDvEfFSrx1xYygGQ4FypyrK8vEBmb ws1wOzmGK3Z2PDQwTshywvFXQNu9BNZiCq2TFOm0kARshVkwhUCIooXYvJcg9l1t lqGNg0bmqyQd0u7M1gqOGfOjBP65SkrrijkpU+7NDqbf732w8+MV2ZZR0dS4NlkQ == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeeghedgudehiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomhepvfgrkhgr shhhihcuufgrkhgrmhhothhouceoohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhird hjpheqnecuggftrfgrthhtvghrnheplefhueegvdejgfejgfdukeefudetvddtuddtueei vedttdegteejkedvfeegfefhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepohdqthgrkhgrshhhihesshgrkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 24 Jun 2021 17:05:52 -0400 (EDT) Date: Fri, 25 Jun 2021 06:05:50 +0900 From: Takashi Sakamoto To: Christophe JAILLET Cc: clemens@ladisch.de, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] ALSA: firewire-lib: Fix 'amdtp_domain_start()' when no AMDTP_OUT_STREAM stream is found Message-ID: Mail-Followup-To: Christophe JAILLET , clemens@ladisch.de, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: <9c9a53a4905984a570ba5672cbab84f2027dedc1.1624560484.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9c9a53a4905984a570ba5672cbab84f2027dedc1.1624560484.git.christophe.jaillet@wanadoo.fr> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Thu, Jun 24, 2021 at 08:49:36PM +0200, Christophe JAILLET wrote: > The intent here is to return an error code if we don't find what we are > looking for in the 'list_for_each_entry()' loop. > > 's' is not NULL if the list is empty or if we scan the complete list. > Introduce a new 'found' variable to handle such cases. > > Fixes: 60dd49298ec5 ("ALSA: firewire-lib: handle several AMDTP streams in callback handler of IRQ target") > Signed-off-by: Christophe JAILLET > --- > We could test with" if (list_entry_is_head(s, &d->streams, list))" > instead, but I find it much less readable. > --- > sound/firewire/amdtp-stream.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c > index aad9778d1c4d..9be2260e4ca2 100644 > --- a/sound/firewire/amdtp-stream.c > +++ b/sound/firewire/amdtp-stream.c > @@ -1943,6 +1943,7 @@ int amdtp_domain_start(struct amdtp_domain *d, unsigned int tx_init_skip_cycles, > unsigned int events_per_period = d->events_per_period; > unsigned int queue_size; > struct amdtp_stream *s; > + bool found = false; > int err; > > if (replay_seq) { > @@ -1955,10 +1956,12 @@ int amdtp_domain_start(struct amdtp_domain *d, unsigned int tx_init_skip_cycles, > > // Select an IT context as IRQ target. > list_for_each_entry(s, &d->streams, list) { > - if (s->direction == AMDTP_OUT_STREAM) > + if (s->direction == AMDTP_OUT_STREAM) { > + found = true; > break; > + } > } > - if (!s) > + if (!found) > return -ENXIO; > d->irq_target = s; > > -- > 2.30.2 Indeed. Nice to catch it. The bug affects Linux kernel v5.5 or later. Acked-by: Takashi Sakamoto In kernel v5.10 or later, we can use 'list_entry_is_head()' macro added by a commit e130816164e2 ("include/linux/list.h: add a macro to test if entry is pointing to the head"). However the development of ALSA firewire stack is out-of-tree repository for my convenience to backport it to kernel v4.17 or later (I need testers...), so I prefer your change. Thanks Takashi Sakamoto