All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: pcm: oss: Compare max buffer size in bytes
@ 2026-11-12 12:34 Takashi Iwai
  2026-11-12 12:49 ` sashiko-bot
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2026-11-12 12:34 UTC (permalink / raw)
  To: linux-sound

We introduced the upper-limit check of the buffer size for PCM OSS to
1MB bytes, but at one place (for PCM OSS plugin-base), the check was
applied at a wrong position: the size is compared before scaling down
to byte size, so it's limiting essentially to 1MB bits, i.e. 128kB
bytes, instead.

Although 128kB is enough in practical use cases, it's better to align
with other places for the code consistency.  So this patch moves the
check to the right position after conversion to bytes, so that it can
limit to the correct size, 1MB bytes.

Fixes: efb6402c3c4a ("ALSA: oss: Fix PCM OSS buffer allocation overflow")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/core/oss/pcm_plugin.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
index 3de713779993..c5b3c67345ee 100644
--- a/sound/core/oss/pcm_plugin.c
+++ b/sound/core/oss/pcm_plugin.c
@@ -48,12 +48,12 @@ static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t
 	if (width < 0)
 		return width;
 	size = array3_size(frames, format->channels, width);
-	/* check for too large period size once again */
-	if (size > 1024 * 1024)
-		return -ENOMEM;
 	if (snd_BUG_ON(size % 8))
 		return -ENXIO;
 	size /= 8;
+	/* check for too large period size once again */
+	if (size > 1024 * 1024)
+		return -ENOMEM;
 	if (plugin->buf_frames < frames) {
 		kvfree(plugin->buf);
 		plugin->buf = kvzalloc(size, GFP_KERNEL);
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-12 13:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12 12:34 [PATCH] ALSA: pcm: oss: Compare max buffer size in bytes Takashi Iwai
2026-11-12 12:49 ` sashiko-bot
2026-11-12 13:21   ` Takashi Iwai

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.