From: sashiko-bot@kernel.org
To: "Takashi Iwai" <tiwai@suse.de>, linux-sound@vger.kernel.org
Subject: Re: [PATCH v3 1/3] ALSA: pcm: Avoid forcibly changing to OPEN state at hw_params errors
Date: Thu, 03 Dec 2026 12:09:31 +0000 [thread overview]
Message-ID: <sashiko-outbox-247700@kernel.org> (raw)
In-Reply-To: <20261203113424.1222171-2-tiwai@suse.de>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ALSA: pcm: snd_pcm_oss_make_ready() lock gap causes spurious
-EBADFD
--
commit 9db40700c95711b404818acc9c231037d80cf17a
Author: Takashi Iwai <tiwai@suse.de>
ALSA: pcm: Avoid forcibly changing to OPEN state at hw_params errors
This commit skips the state reset and buffer release on snd_pcm_hw_params()
errors when the substream buffer is mmapped, and adds a runtime->oss.params
check in snd_pcm_oss_prepare() to catch failed hw_params calls.
Link: https://lore.kernel.org/20261202140117.1164633-1-ahmedabdelmoumen05@gmail.com
> diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
> index 3c2ac8966d5e3..35a5fa67d6f9b 100644
> --- a/sound/core/oss/pcm_oss.c
> +++ b/sound/core/oss/pcm_oss.c
> @@ -1146,6 +1146,10 @@ static int snd_pcm_oss_prepare(struct snd_pcm_substream *substream)
> int err;
> struct snd_pcm_runtime *runtime = substream->runtime;
>
> + /* previous hw_params failed? */
> + if (runtime->oss.params)
> + return -EBADFD;
> +
> err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_PREPARE, NULL);
> if (err < 0) {
> pcm_dbg(substream->pcm,
[Severity: Medium]
Can a concurrent valid parameter-change ioctl set runtime->oss.params here
and cause snd_pcm_oss_prepare() to return a spurious -EBADFD?
snd_pcm_oss_make_ready() drops runtime->oss.params_lock between
snd_pcm_oss_change_params() and snd_pcm_oss_prepare(), so a concurrent
ioctl such as snd_pcm_oss_set_rate() can set runtime->oss.params = 1 in
that window:
CPU0 CPU1
snd_pcm_oss_make_ready()
snd_pcm_oss_change_params()
/* drops params_lock */
snd_pcm_oss_set_rate()
lock_params(runtime)
runtime->oss.params = 1
unlock(&runtime->oss.params_lock)
lock(&runtime->oss.params_lock)
snd_pcm_oss_prepare()
if (runtime->oss.params)
return -EBADFD; <-- spurious error
Callers of snd_pcm_oss_make_ready() such as SNDCTL_DSP_SETTRIGGER then fail
with -EBADFD instead of applying the updated parameters, and in
snd_pcm_oss_poll() this aborts capture retrigger after
need_input_retrigger() has already cleared runtime->oss.trigger.
Checking (runtime->oss.params || runtime->oss.prepare) and acquiring
runtime->oss.params_lock once in snd_pcm_oss_make_ready() to call
snd_pcm_oss_make_ready_locked() would close the window and apply concurrent
parameter updates cleanly.
Separately, the commit message misspells snd_pcm_oss_make_ready() as
snd_pcm_make_ready() and snd_pcm_oss_change_params() as
snd_pcm_oss_change_param().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203113424.1222171-1-tiwai@suse.de?part=1
next prev parent reply other threads:[~2026-12-03 12:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 11:34 [PATCH v3 0/3] ALSA: pcm: Workarounds for OSS mmap issues Takashi Iwai
2026-12-03 11:34 ` [PATCH v3 1/3] ALSA: pcm: Avoid forcibly changing to OPEN state at hw_params errors Takashi Iwai
2026-12-03 12:09 ` sashiko-bot [this message]
2026-12-03 11:34 ` [PATCH v3 2/3] ALSA: pcm: Reject hw_params with buffer size changes while mmapped Takashi Iwai
2026-12-03 11:34 ` [PATCH v3 3/3] ALSA: pcm: Prohibit buffer (re-)allocation/free during mmap Takashi Iwai
2026-12-03 12:00 ` sashiko-bot
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-247700@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tiwai@suse.de \
/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.