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=1796181501; b=PeJq61mVCD+6FtBVAJGO4Db30qUey7Z9MLggrvBULfGpiJ6gNa8me+dQvsVuOn9qcIhI ghgrLsfjOf5TLJDK9aR650jzjvSGZReYxEJe4SvJBRHUwO5MNO3+GW92FpycNY8q0PREB vKj+hk5pvWmsQST8sjwskQecg/JQaK4dQL+SrGw/ozF2I+iO/se+OUNjblv9uB7kEP5+9 OMo0p/SEAIFxTdUHzeAbe2Y1WxxNwMpFwCzOIicelQC2+8oXeknOBR+VftpSBRpd+AqK/ HRi0e5TVugjj4kzLVxjCtgsD7d5fkk4yHSLj0bHSVymvNqTtju3YRDWjVDeBEvPajAA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796181501; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=s90IGwiwYHpubteOY+aJXOenYmPkm8S5sYp71/pQrGg=; b=5KXtP306G4elRnW5CUiJo5Xv19qEJOjkuyS4xt5tFQhBgie2Qxrde24BcodLMf7B/jdZ rRO23VEqLCQSF1OujDGUqmQBZyy8Eg84dVCCzsB/tPYVbSW2j9kS2TnGJ2BVccwEOHHgX vcetoupy6+UeOFOY+a29xtB7Xx4dXlo78jMxrtkHzQ1JVUEJyXjRZXEM/81bbJtTchc3s tX2NRTraW5KzBK0lmkhBX3qSVSgNyya2SgIqslYZXZwDDo/1FzMNn56al1e5hdXu8T9yc ZwGelrebHJh0b7CZRfpvywBHfF6XIFQP/z6CSb40VHoeLvTqewEVJqxGZ4K4TsaCMpA== 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=Qyk4iYEu; 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 57801606A322 for ; Wed, 2 Dec 2026 03:18:21 +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=Qyk4iYEu Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF0A41F0089C; Wed, 2 Dec 2026 03:18:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796181500; bh=s90IGwiwYHpubteOY+aJXOenYmPkm8S5sYp71/pQrGg=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Qyk4iYEuCwM1rjVtqFZly3ZmL57xa7qCgoIIK1cnJT+6PxAVXB9Akn014LgMpkxB9 ydaU1dIqAWTJCC2f5CU0axDqJUw9BOpA3V6dcdt/RB/UTkCSgN9V5JwFomKwq3YR3y YQqjIoViClsZ2hmFmtL8WkVfn8m/lgIrTAoCZ4BqkxSdZbytQnoXprMS1krf7VORi+ 0RDhfz2vPi6jsx5oKDsAUbI/YvEfUYEtBNYek1fr57L4IdrStmXMLukVnehYQFtqI/ bwq1IvSm8q8oPsadUvLGJOxgvojOk0bZFW4IKfOnSnjlpp2t6iZ+Qqbt4bAWHMXVqF ZsWCfWvlxo8yA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] ALSA: aoa: i2sbus: serialize codec_list and pcm check-and-free sequences Reply-To: sashiko-reviews@lists.linux.dev To: "Hanxiang Xu" Cc: linux-sound@vger.kernel.org In-Reply-To: <20261202103500.6-1-xuhx@hust.edu.cn> References: <20261202103500.6-1-xuhx@hust.edu.cn> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 03:18:20 +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 2 potential issues to consider: - [High] ALSA: aoa: i2sbus: undeclared i2sbus_pcm_mutex in i2sbus_attach_codec() - [Low] ALSA: aoa: i2sbus: missing Fixes trailer on bug-fix commit -- commit 0568c140cfaf58b5209a2f736b6288cd639d9e34 Author: Hanxiang Xu > ALSA: aoa: i2sbus: serialize codec_list and pcm check-and-free sequences > > i2sbus_detach_codec() manipulates dev->codec_list without any lock > and ends in an unlocked check-then-free: > "if (list_empty(&dev->codec_list) && dev->pcm) > snd_device_free(dev->pcm->card, dev->pcm)". The callers hold device > locks that do not serialize against each other: codec drivers detach > from i2c driver context (each holding its own i2c client lock) while > bus removal runs from soundbus/macio context, and a bus can host two > codecs (MAX_CODECS_PER_BUS). Two concurrent codec detaches therefore > both pass the dev->pcm check before either clears it and both run > snd_device_free() on the same pcm, double-freeing it (the second call > also walks card->devices while the first is freeing the snd_device > wrapper). > > Serialize attach/detach with a mutex and claim dev->pcm before > calling snd_device_free() so a concurrent detach cannot re-enter the > free. > > Cc: > Signed-off-by: Hanxiang Xu [Severity: Low] Should this bug fix include a Fixes: tag? Fixes: f3d9478b2ce4 ("[ALSA] snd-aoa: add snd-aoa") > diff --git a/sound/aoa/soundbus/i2sbus/pcm.c b/sound/aoa/soundbus/i2sbus/= pcm.c > index 63004ece94f93..3fbc34a247988 100644 > --- a/sound/aoa/soundbus/i2sbus/pcm.c > +++ b/sound/aoa/soundbus/i2sbus/pcm.c > @@ -862,6 +862,8 @@ i2sbus_attach_codec(struct soundbus_dev *dev, struct = snd_card *card, > struct i2sbus_dev *i2sdev =3D soundbus_dev_to_i2sbus_dev(dev); > struct codec_info_item *cii; > =20 > + guard(mutex)(&i2sbus_pcm_mutex); > + > if (!dev->pcmname || dev->pcmid =3D=3D -1) { > printk(KERN_ERR "i2sbus: pcm name and id must be set!\n"); > return -EINVAL; > @@ -1018,10 +1020,18 @@ i2sbus_attach_codec(struct soundbus_dev *dev, str= uct snd_card *card, > return err; > } > =20 > +/* > + * codec attach/detach (i2c driver context) and bus removal > + * (soundbus/macio context) hold different device locks; serialize the > + * codec_list and dev->pcm sequences between them. > + */ > +static DEFINE_MUTEX(i2sbus_pcm_mutex); [Severity: High] Does this fail to build because i2sbus_pcm_mutex is defined below i2sbus_attach_codec(), where it is already used without a prior declaration? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202103500.6-1-= xuhx@hust.edu.cn?part=3D1