From: sashiko-bot@kernel.org
To: "Hanxiang Xu" <xuhx@hust.edu.cn>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH] ALSA: aoa: i2sbus: serialize codec_list and pcm check-and-free sequences
Date: Wed, 02 Dec 2026 03:18:20 +0000 [thread overview]
Message-ID: <sashiko-outbox-244754@kernel.org> (raw)
In-Reply-To: <20261202103500.6-1-xuhx@hust.edu.cn>
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 <xuhx@hust.edu.cn>
> 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: <stable@vger.kernel.org>
> Signed-off-by: Hanxiang Xu <xuhx@hust.edu.cn>
[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 = soundbus_dev_to_i2sbus_dev(dev);
> struct codec_info_item *cii;
>
> + guard(mutex)(&i2sbus_pcm_mutex);
> +
> if (!dev->pcmname || dev->pcmid == -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, struct snd_card *card,
> return err;
> }
>
> +/*
> + * 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?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202103500.6-1-xuhx@hust.edu.cn?part=1
prev parent reply other threads:[~2026-12-02 3:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 2:35 [PATCH] ALSA: aoa: i2sbus: serialize codec_list and pcm check-and-free sequences Hanxiang Xu
2026-12-02 3:18 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-244754@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=xuhx@hust.edu.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.