From: sashiko-bot@kernel.org
To: "Sreeraj S Kurup" <sreekuttan2156239@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH] ALSA: vmaster: Retry follower initialization on failure
Date: Thu, 26 Nov 2026 07:39:00 +0000 [thread overview]
Message-ID: <sashiko-outbox-234965@kernel.org> (raw)
In-Reply-To: <20261126072220.4496-1-sreekuttan2156239@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] ALSA: vmaster: uninitialized uval passed in sync_followers()
on init failure
- [Medium] ALSA: vmaster: race on follower->info.count in
follower_init() under read lock
- [Low] ALSA: vmaster: missing Fixes trailer in commit message
--
commit 66386ac7ea387abe74516a97a7585d68c50638a0
Author: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
> ALSA: vmaster: Retry follower initialization on failure
>
> Reset the follower count when the initial follower update
> fails.
>
> This allows follower initialization to be retried on the
> next access.
>
> Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
[Severity: Low]
This is a bug fix for follower initialization failure handling. Should
the commit message include a Fixes tag, such as:
Fixes: 3b0a5f22d464 ("[ALSA] Add virtual master control helpers")
or:
Fixes: 2e2c177ca84a ("ALSA: vmaster: Propagate slave error")
> diff --git a/sound/core/vmaster.c b/sound/core/vmaster.c
> index f43144ba27978..d97d7bb33e166 100644
> --- a/sound/core/vmaster.c
> +++ b/sound/core/vmaster.c
> @@ -102,7 +102,14 @@ static int follower_init(struct link_follower *follower)
> follower->info.min_val = uinfo->value.integer.min;
> follower->info.max_val = uinfo->value.integer.max;
>
> - return follower_update(follower);
> + err = follower_update(follower);
> + if (err < 0) {
> + /* allow initialization to be retried */
> + follower->info.count = 0;
> + return err;
> + }
> +
> + return 0;
> }
[Severity: Medium]
Can resetting follower->info.count to 0 here cause sync_followers() to
pass uninitialized or stale uval contents to follower->follower.put()?
master_init() only initializes the first follower in master->followers.
When sync_followers() iterates over a subsequent follower whose
follower_update() fails, follower_get_val() returns an error without
populating uval->value.integer.value[]:
sound/core/vmaster.c:sync_followers() {
struct snd_ctl_elem_value *uval __free(kfree) =
kmalloc_obj(*uval);
...
list_for_each_entry(follower, &master->followers, list) {
master->val = old_val;
uval->id = follower->follower.id;
follower_get_val(follower, uval);
master->val = new_val;
follower_put_val(follower, uval);
}
sync_followers() ignores the error from follower_get_val() and calls
follower_put_val(follower, uval). Because follower->info.count is now 0,
follower_put_val() skips its per-channel attenuation and clamping loop
and passes uval directly to follower->follower.put(), writing unclamped
stale values (from the previous follower) or uninitialized heap memory
(if the first follower has SND_CTL_FOLLOWER_NEED_UPDATE) into the
underlying control.
[Severity: Medium]
Can a concurrent control read or info call observe follower->info.count
as non-zero before follower_update() finishes, bypassing initialization
when follower_update() fails?
snd_ctl_elem_read() and snd_ctl_elem_info() hold only a shared read lock
on card->controls_rwsem when calling master_get(), master_info(), or
follower_get():
CPU0 CPU1
follower_get_val()
follower_init()
follower->info.count =
uinfo->count;
follower_update()
kzalloc_obj(*uctl)
master_get()
master_init()
follower_init()
if (follower->info.count)
return 0;
master->info.count = 1; <-- skips retry
follower.get() -> fails
follower->info.count = 0;
If CPU1 enters follower_init() through master_init(), it marks the master
initialized from a follower that failed to initialize; if CPU1 enters
through follower_get_val(), it copies unpopulated follower->vals[] to
userspace. Setting follower->info.count only after follower_update()
succeeds (passing the count to follower_update() or using a local info
struct) would avoid publishing an incompletely initialized follower.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126072220.4496-1-sreekuttan2156239@gmail.com?part=1
prev parent reply other threads:[~2026-11-26 7:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 7:22 [PATCH] ALSA: vmaster: Retry follower initialization on failure Sreeraj S Kurup
2026-11-26 7:39 ` 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-234965@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sreekuttan2156239@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox