diff mbox series

[Impish,SRU,1/1] ALSA: usb-audio: Fix packet size calculation regression

Message ID 20220331032835.138788-2-po-hsu.lin@canonical.com
State New
Headers show
Series [Impish,SRU,1/1] ALSA: usb-audio: Fix packet size calculation regression | expand

Commit Message

Po-Hsu Lin March 31, 2022, 3:28 a.m. UTC
From: Takashi Iwai <tiwai@suse.de>

BugLink: https://bugs.launchpad.net/bugs/1966066

The commit d215f63d49da ("ALSA: usb-audio: Check available frames for
the next packet size") introduced the available frame size check, but
the conversion forgot to initialize the temporary variable properly,
and it resulted in a bogus calculation.  This patch fixes it.

Fixes: d215f63d49da ("ALSA: usb-audio: Check available frames for the next packet size")
Reported-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20211001104417.14291-1-colin.king@canonical.com
Link: https://lore.kernel.org/r/20211001105425.16191-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
(cherry picked from commit 23939115be181bc5dbc33aa8471adcdbffa28910)
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
 sound/usb/endpoint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 0ba7b35..8e9ed31 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -182,7 +182,7 @@  static int next_packet_size(struct snd_usb_endpoint *ep, unsigned int avail)
 	if (ep->fill_max)
 		return ep->maxframesize;
 
-	sample_accum += ep->sample_rem;
+	sample_accum = ep->sample_accum + ep->sample_rem;
 	if (sample_accum >= ep->pps) {
 		sample_accum -= ep->pps;
 		ret = ep->packsize[1];