From: Takashi Iwai <tiwai@suse.de>
To: linux-sound@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 11/11] ALSA: line6: Fix handling of zero-length capture packets
Date: Thu, 8 Oct 2026 21:25:51 +0200 [thread overview]
Message-ID: <20261008192553.300025-12-tiwai@suse.de> (raw)
In-Reply-To: <20261008192553.300025-1-tiwai@suse.de>
The LINE6 playback engine assumes that line6pcm->prev_fsize=0
indicates that there was no input packet to be processed, and
synthesizes the frames. But, when a capture stream receives a
zero-length (or a very small size) packet, it sets 0 to prev_fsize,
while playback engine still believes it's for synthesis, hence it
tries to copy the larger data than the actual input data.
As prev_fsize=0 can't be a good indication for "no input", change the
meaning slightly: now prev_fsize=-1 means no input, while prev_fsize=0
means it's a zero-length packet.
Fixes: 1027f476f507 ("staging: line6: sync with upstream")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/usb/line6/pcm.c | 4 +++-
sound/usb/line6/playback.c | 4 ++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c
index 998869dc4613..e2b99e7a08e0 100644
--- a/sound/usb/line6/pcm.c
+++ b/sound/usb/line6/pcm.c
@@ -217,7 +217,7 @@ static void line6_stream_stop(struct snd_line6_pcm *line6pcm, int direction,
if (direction == SNDRV_PCM_STREAM_CAPTURE) {
guard(spinlock_irqsave)(&pstr->lock);
line6pcm->prev_fbuf = NULL;
- line6pcm->prev_fsize = 0;
+ line6pcm->prev_fsize = -1;
}
}
@@ -538,6 +538,8 @@ int line6_init_pcm(struct usb_line6 *line6,
line6pcm->volume_playback[0] = line6pcm->volume_playback[1] = 255;
line6pcm->volume_monitor = 255;
line6pcm->line6 = line6;
+ line6pcm->prev_fbuf = NULL;
+ line6pcm->prev_fsize = -1;
spin_lock_init(&line6pcm->out.lock);
spin_lock_init(&line6pcm->in.lock);
diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c
index aa6ddf8746a0..6682ebaac646 100644
--- a/sound/usb/line6/playback.c
+++ b/sound/usb/line6/playback.c
@@ -171,7 +171,7 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm)
&urb_out->iso_frame_desc[i];
fsize = line6pcm->prev_fsize;
- if (fsize == 0) {
+ if (fsize == -1) {
int n;
line6pcm->out.count += frame_increment;
@@ -271,7 +271,7 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm)
bytes_per_frame);
}
line6pcm->prev_fbuf = NULL;
- line6pcm->prev_fsize = 0;
+ line6pcm->prev_fsize = -1;
}
spin_unlock(&line6pcm->in.lock);
--
2.55.0
prev parent reply other threads:[~2026-10-08 19:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 19:25 [PATCH 00/11] ALSA: yet a few more fixes for AI bug reports Takashi Iwai
2026-10-08 19:25 ` [PATCH 01/11] ALSA: hda: intel: Cancel delayed work at shutdown, too Takashi Iwai
2026-10-08 19:25 ` [PATCH 02/11] ALSA: hda: Disable unsol event handling at error and shutdown paths Takashi Iwai
2026-10-08 19:25 ` [PATCH 03/11] ALSA: hda: Add lock around codec->registered flag manipulations Takashi Iwai
2026-10-09 10:13 ` kernel test robot
2026-10-09 10:56 ` kernel test robot
2026-10-08 19:25 ` [PATCH 04/11] ALSA: hda: Add NULL check for the driver pointer at unsol event work Takashi Iwai
2026-10-08 19:25 ` [PATCH 05/11] ALSA: caiaq: Register card at the final step Takashi Iwai
2026-10-08 19:25 ` [PATCH 06/11] ALSA: caiaq: Fix races at MIDI URB and trigger accesses Takashi Iwai
2026-10-08 19:25 ` [PATCH 07/11] ALSA: usb: us16x08: Fix racy accesses of mixer elements Takashi Iwai
2026-10-08 19:25 ` [PATCH 08/11] ASoC: fsl_asrc_m2m: Fix bogus compress task pointer assignments Takashi Iwai
2026-10-08 19:25 ` [PATCH 09/11] ALSA: line6: Reject too small max packet sizes Takashi Iwai
2026-10-08 19:25 ` [PATCH 10/11] ALSA: line6: Fix potential OOB write in line6_capture_copy() Takashi Iwai
2026-10-08 19:25 ` Takashi Iwai [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=20261008192553.300025-12-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
/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