Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp464923pxv; Thu, 24 Jun 2021 11:52:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwapGT4fPtEAe9tW0afWOPlc1Kpssj64z52hZJrG2y+TaM12ZaSrC7gId7eHmAb8BUm9/E0 X-Received: by 2002:aa7:da96:: with SMTP id q22mr9472185eds.307.1624560726285; Thu, 24 Jun 2021 11:52:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624560726; cv=none; d=google.com; s=arc-20160816; b=hgIJbBW5jdMQdFNlcJLAVrTPTKDB4n7J0vSXEWeLgSvqmvmhk6RExQo0yPS/FgHCci 3ckOMcqSHxC+JZzIcb0/OLXWy2d+bstDQUS3xRIMGKeOvPshgGXpdEfXfaH6CRdVy/v9 ucVTYgUsd5pMGkzqh++qBX2n5kzCo8OaNEVilcLEomMuAG55B73zLEt/RfkFU7xnh4Oh UZA8oDh9KRuV2dJxQ0M/UvsA0+Gipi121g5HaJEzprK+k6FczTVS+NZ24MdHaoAHUTx9 wNpU7pHcm3N97INnhz0OgQHJjoQ2Ug301LN832lTueca6al/j0I+LfCu8e9ulyBqUrHz SJ+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=3W+cQIk4jK0uXBQ+T0O+fMukvfD9oyWvGsfH79gfrJo=; b=mb1iue2Da0wKiDU6EU21PyypzIkYoB47g/Epzmv22ZqAC3ZcnG2bpG9jo1pu6qudTU est87NLzA6cvIa5kXub77Z2QiXhD4L99N1hU32I/jNg8IgjDFk0cBhz1tgIpFtkTmWOB x+fznhTHiPQN75kesVtbgOXP0+xOOy2+L/TsdpGWK3Ww+v73h3orT0Csm7nuBuIsWOiE VU1PJxisWkf1fPA7Xs8aRQde8vWbolojyjMU00PkkX4fs0arvpc6+o7EM7i6H+QHPCtB A+/wCzTxV6juhxPxOPiCAMUHa1Tn2B8aOI4hj+VOWuHvbBC8CxgKHsCUuz8mSl07wHE2 CJnQ== ARC-Authentication-Results: i=1; mx.google.com; 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 y16si3875911edd.314.2021.06.24.11.51.41; Thu, 24 Jun 2021 11:52:06 -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; 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 S232538AbhFXSwR (ORCPT + 99 others); Thu, 24 Jun 2021 14:52:17 -0400 Received: from smtp12.smtpout.orange.fr ([80.12.242.134]:39075 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230450AbhFXSwR (ORCPT ); Thu, 24 Jun 2021 14:52:17 -0400 Received: from localhost.localdomain ([86.243.172.93]) by mwinf5d23 with ME id M6pu2500121Fzsu036puNL; Thu, 24 Jun 2021 20:49:56 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 24 Jun 2021 20:49:56 +0200 X-ME-IP: 86.243.172.93 From: Christophe JAILLET To: clemens@ladisch.de, o-takashi@sakamocchi.jp, perex@perex.cz, tiwai@suse.com Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] ALSA: firewire-lib: Fix 'amdtp_domain_start()' when no AMDTP_OUT_STREAM stream is found Date: Thu, 24 Jun 2021 20:49:36 +0200 Message-Id: <9c9a53a4905984a570ba5672cbab84f2027dedc1.1624560484.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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