From: sashiko-bot@kernel.org
To: "Takashi Iwai" <tiwai@suse.de>, linux-sound@vger.kernel.org
Subject: Re: [PATCH 4/4] ALSA: pcm: Don't reallocate for the same sized buffers
Date: Wed, 02 Dec 2026 16:04:38 +0000 [thread overview]
Message-ID: <sashiko-outbox-246189@kernel.org> (raw)
In-Reply-To: <20261202155431.720872-5-tiwai@suse.de>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] ALSA: pcm: skipped buffer setup in snd_pcm_lib_malloc_pages()
--
commit 5e5fb9073b231ba56d65e8237f08c42e058554e1
Author: Takashi Iwai <tiwai@suse.de>
ALSA: pcm: Don't reallocate for the same sized buffers
This commit skips buffer reallocation in snd_pcm_lib_malloc_pages() when
the requested buffer size matches runtime->dma_bytes.
> diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c
> index 7aaa45f3bac14..7418da6694094 100644
> --- a/sound/core/pcm_memory.c
> +++ b/sound/core/pcm_memory.c
> @@ -431,6 +431,9 @@ int snd_pcm_lib_malloc_pages(struct snd_pcm_substream *substream, size_t size)
> runtime = substream->runtime;
> card = substream->pcm->card;
>
> + if (runtime->dma_bytes == size)
> + return 0; /* no need to change */
> +
> if (atomic_read(&substream->mmap_count))
> return -EBADFD;
>
[Severity: High]
Can this skip snd_pcm_set_runtime_buffer() on the initial hw_params call
when a driver presets runtime->dma_bytes during open()?
Some drivers using managed buffers via snd_pcm_set_fixed_buffer_all()
initialize runtime->dma_bytes in their open callback while
runtime->dma_buffer_p and runtime->dma_area are still NULL:
sound/soc/qcom/lpass-platform.c:lpass_platform_pcmops_open() {
...
snd_soc_set_runtime_hwparams(substream, &lpass_platform_pcm_hardware);
runtime->dma_bytes = lpass_platform_pcm_hardware.buffer_bytes_max;
break;
...
}
When userspace requests a buffer of that size in snd_pcm_hw_params(),
snd_pcm_lib_malloc_pages() now returns 0 before attaching
substream->dma_buffer to runtime. That leaves runtime->dma_area NULL and
causes a NULL pointer dereference in lpass_platform_copy() during PCM data
transfers.
Should this check also require runtime->dma_buffer_p to be non-NULL?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202155431.720872-1-tiwai@suse.de?part=4
prev parent reply other threads:[~2026-12-02 16:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 15:54 [PATCH 0/4] ALSA: pcm: Workarounds for OSS mmap issues Takashi Iwai
2026-12-02 15:54 ` [PATCH 1/4] ALSA: pcm: Avoid forcibly changing to OPEN state at hw_params errors Takashi Iwai
2026-12-02 15:54 ` [PATCH 2/4] ALSA: pcm: Reject hw_params with buffer size changes while mmapped Takashi Iwai
2026-12-02 15:54 ` [PATCH 3/4] ALSA: pcm: Prohibit buffer (re-)allocation/free during mmap Takashi Iwai
2026-12-02 15:54 ` [PATCH 4/4] ALSA: pcm: Don't reallocate for the same sized buffers Takashi Iwai
2026-12-02 16:04 ` 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-246189@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.