From: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
To: perex@perex.cz, tiwai@suse.com, tiwai@suse.de
Cc: linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org,
Sreeraj S Kurup <sreekuttan2156239@gmail.com>
Subject: [PATCH v2] ALSA: linear: Check frame count for all channels
Date: Thu, 5 Nov 2026 14:22:26 +0000 [thread overview]
Message-ID: <20261105142226.3079-1-sreekuttan2156239@gmail.com> (raw)
linear_transfer() checks the available frame count only for
the first destination channel.
Check the available frame count of all source and destination
channels before converting samples.
Use the smallest available frame count to make sure that
conversion does not read or write beyond the channel buffers.
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
v2:
Add missing mailing-list recipients
sound/core/oss/linear.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/sound/core/oss/linear.c b/sound/core/oss/linear.c
index 6e51cfdca238..7765ac0ec400 100644
--- a/sound/core/oss/linear.c
+++ b/sound/core/oss/linear.c
@@ -6,6 +6,7 @@
*/
#include <linux/time.h>
+#include <linux/minmax.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include "pcm_plugin.h"
@@ -75,6 +76,8 @@ static snd_pcm_sframes_t linear_transfer(struct snd_pcm_plugin *plugin,
struct snd_pcm_plugin_channel *dst_channels,
snd_pcm_uframes_t frames)
{
+ unsigned int channel;
+
if (snd_BUG_ON(!plugin || !src_channels || !dst_channels))
return -ENXIO;
if (frames == 0)
@@ -92,8 +95,12 @@ static snd_pcm_sframes_t linear_transfer(struct snd_pcm_plugin *plugin,
}
}
#endif
- if (frames > dst_channels[0].frames)
- frames = dst_channels[0].frames;
+ for (channel = 0; channel < plugin->src_format.channels; channel++) {
+ frames = min(frames, src_channels[channel].frames);
+
+ frames = min(frames, dst_channels[channel].frames);
+ }
+
convert(plugin, src_channels, dst_channels, frames);
return frames;
}
--
2.55.0
next reply other threads:[~2026-11-05 14:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 14:22 Sreeraj S Kurup [this message]
2026-11-05 15:08 ` Takashi Iwai
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=20261105142226.3079-1-sreekuttan2156239@gmail.com \
--to=sreekuttan2156239@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®