From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796235747; b=qSmiQu5L+Uwdnqi2NNcbVwr6UTcuIUkffPeFvDouisEoctn7gPwCVmKBvj8f8gjAm62V xPK9s+ycyI+vR0A2NFfReDFWNah7r8Xi2gM5uQSL6TY1nJuRVyN9uk2V1d6UjOfHc+XAj V84q2l8P5vqRtR0wePicjtsnpCjO8dLBmig/H2/UmBfzaC18jGZxRjn12mN31BINTC9EU u0DOI/8sZ+r9o0ENPgKNIsI8KNe6Dhrng/luUmn9dT2iV6xBayedCEBxGCTKf+FxIUJhW EAeN3NtzjdGz+m6gzR5kZS6bHS/0Z/FC+my0kzFn+Lef9xua45Z4mGUdQ3gIZEl4z5w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796235747; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=NW09lPWM6gZVS78y8k1OK6fBRjIhTF/w+j3wyOwtffM=; b=1RAyZFoyYgMBlxSw8QgAGRwVITMQTVsAuf7rCr9P8p7f6xMkgm39aaCo1g9Mg+9g+Ba4 CT6MDz2eXhLumHvCTy9FgJrVdlK9Pld1byARo9/vxo5sK8Shnwi2i66CCcgucl1SJmuTO 0TnEvOdI3qstb9iW6PN3PE/Tybjy8aNwgtbvvY2rkRPsC1t7Ec8o71oL7AHKGd6scXDXc IX+K2kdOD7RTgpZNGPDf01tErF1yXOiBpYi883ij4c3MP4iLISpb4/036ErZauWEtHn0d 78I2Cn9jWHf7JJmhEV9OHg21NnfN8orzWq+Cv2PnR5hlRiBYLbXGF0U7PgbgZGUrPDg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=D1FxV+bx; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36342606A322 for ; Wed, 2 Dec 2026 18:22:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=D1FxV+bx Received: by smtp.kernel.org (Postfix) with ESMTPSA id B96551F00893; Wed, 2 Dec 2026 18:22:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796235746; bh=NW09lPWM6gZVS78y8k1OK6fBRjIhTF/w+j3wyOwtffM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=D1FxV+bx1Q3Ie/do+Pier0c0gC0sUliIX4fSy99qccjCbht76QUoP6ZlZwbjtOaeG JCW1sOsa30r2f4ypQOtGL6k3HxrVHCLPPKDHGsieXhaz6jy02fJB4a4vKm7Ft8Om35 B2ckElif3eBceN0KO5m/pRXrSmu1evRvoag89jFHiUjRA89snby5k8JFG5Z0m6rFBR 7eYS2V0pKjLJVivHrI0w8qi1NWc/ku4R4scd34U0GTYmM/8ShNZbxYzpM3XkRGJ5vA ruot/vnhvgnLgx8/3SgfaNSKTtrR+fgZKg86mAu88ekTiH22sX77y495xH+rgCNiPz 5/KNlzHENswOw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 2/2] ALSA: usb-audio: Reuse active sync endpoint format for implicit feedback Reply-To: sashiko-reviews@lists.linux.dev To: "Lee Volkov" Cc: linux-sound@vger.kernel.org In-Reply-To: <20261202181013.145045-3-voilthuman@gmail.com> References: <20261202181013.145045-1-voilthuman@gmail.com> <20261202181013.145045-3-voilthuman@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 18:22:26 +0000 X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] ALSA: usb-audio: stale sync format in snd_usb_find_implicit_fb_sync_format() -- commit 6b635db94b2380ef0172259cb4f8263eb84ae716 Author: Lee Volkov ALSA: usb-audio: Reuse active sync endpoint format for implicit feedback This commit checks if the implicit-feedback sync endpoint is already open with a compatible audioformat and reuses it instead of scanning subs->fmt_list for a new altsetting. > diff --git a/sound/usb/implicit.c b/sound/usb/implicit.c > index bd4d569a8190c..56fb87345e9f5 100644 > --- a/sound/usb/implicit.c > +++ b/sound/usb/implicit.c [ ... ] > @@ -475,6 +478,25 @@ snd_usb_find_implicit_fb_sync_format(struct snd_usb_= audio *chip, > if (!subs) > goto end; > =20 > + /* > + * If the shared sync endpoint is already open in a compatible format, > + * reuse that active audioformat instead of picking another altsetting > + * and failing endpoint_compatible() later. > + */ > + scoped_guard(mutex, &chip->mutex) { > + ep =3D snd_usb_get_endpoint(chip, target->sync_ep); > + if (ep && ep->opened && ep->cur_audiofmt && > + match_endpoint_audioformats(subs, ep->cur_audiofmt, > + params_rate(params), > + params_channels(params), > + params_format(params))) > + active_fmt =3D ep->cur_audiofmt; > + } > + if (active_fmt) { > + sync_fmt =3D active_fmt; > + goto end; > + } [Severity: Medium] Can a repeated hw_params call without an intervening hw_free pin the sync endpoint to the calling substream's own about-to-be-closed sync_fmt? snd_usb_hw_params() calls snd_usb_find_implicit_fb_sync_format() before closing the calling substream's previous endpoints: sound/usb/pcm.c:snd_usb_hw_params() { ... if (fmt->implicit_fb) { sync_fmt =3D snd_usb_find_implicit_fb_sync_format(chip, fmt, hw_params, !subs->direction, &sync_fixed_rate); ... if (subs->data_endpoint) { if (snd_usb_endpoint_compatible(chip, subs->data_endpoint, fmt, hw_params)) goto unlock; if (stop_endpoints(subs, false)) sync_pending_stops(subs); close_endpoints(chip, subs); } } When the counterpart substream is not open, ep->opened is 1 from the calling substream's own subs->sync_endpoint. Because match_endpoint_audioformats() returns 1 for any channel count when the rate and PCM format match, this check matches the old ep->cur_audiofmt and skips the subs->fmt_list scoring loop even when the caller is changing channels and close_endpoints() is about to drop that reference. Reopening the sync endpoint with the stale altsetting can then cause a subsequent open of the counterpart substream with the new channel count to fail in endpoint_compatible() with -EINVAL, or conflict with data_endpoint's new altsetting when target->iface =3D=3D target->sync_iface. Should this check whether the endpoint is actually in use by the counterpart stream (similar to how get_endpoint_in_use() checks ep !=3D ref_ep || ep->opened > 1) before reusing ep->cur_audiofmt? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202181013.1450= 45-1-voilthuman@gmail.com?part=3D2