Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp553371pxv; Thu, 24 Jun 2021 14:06:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcbe7DQKT0CS13ozJIFmnhVEDcMuhKr0ue9Uxbo7GQk8n54EjZtw1Di3/pOcg5qjf9Rr92 X-Received: by 2002:a92:ce50:: with SMTP id a16mr5059622ilr.142.1624568816315; Thu, 24 Jun 2021 14:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624568816; cv=none; d=google.com; s=arc-20160816; b=B7pNU1EO+KgIYc2bTzMWOCkLDZiDdpvlyGyck/79grQPRLc96r2+TtV0oma0qVqzY1 NvHmzD1APibsetEl74xm6YbKwVoEWgisLn2F5TUZc85Z3g5B8y/T1gKEblwCJtM9Cxx/ 38AvlCt0FeROoxVYZZKXkEug1QRxOtRDk0CHwikFwMBiSSG+tchRtbyCs+0PkB8q66iV RIgGma8bmUmG3e7rI1tOrOrc+FQmwC8+i4K0y6cWsOZvOduMk9orLE9hN0yq7ZUE0Uqi t2JXL/mY2dP1wl70+gQS9EA96L/eVEgcmhpzjJnH2gdDwKTIfj9mCcbJ/jRg/Su4kURP G5Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=9jMAnkKABHSlUcjl0Zbwdrv+Qzw4CH1IFEmMt+CBJQM=; b=JvZybFASOSOY/Rs+aFrV9j+t7CXaLg4+Egg75owc8n/Ww37QKd7Ib0Cii7i97msHaI SUDrTUSV9PNteHcoRIo4Wuz32NHE0hJDiloxDt2htnxfECO1uTcMU/otFKxNdBuXPGfu yWDnH6Ddg01UFhe8bN17nU3izi5wHHBlFCJs/CVbyUP+wyPQqig4nS5ddaIcCvdYcZEo ixdQUSmdW87ZDS58RVEfWzY4bHjFeFS5lggA5EiTAYz7VogmfMjDw2tyoPIhoVia3Rn8 zrFPIxD+GYMLncoKDfD1jyzMF0K9vZdw8S+2l0+jzNUU558IXIt464kbemK/71dEIRsm AsVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm1 header.b=nuN9S+LN; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=f5ewB02t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x6si4488764ilv.67.2021.06.24.14.06.38; Thu, 24 Jun 2021 14:06:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@sakamocchi.jp header.s=fm1 header.b=nuN9S+LN; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=f5ewB02t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232310AbhFXVIQ (ORCPT + 99 others); Thu, 24 Jun 2021 17:08:16 -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