Skip to content

Commit de45fb5

Browse files
tiwaiSasha Levin
authored andcommitted
ALSA: usb-audio: Cap the packet size pre-calculations
[ Upstream commit 7fe8dec ] We calculate the possible packet sizes beforehand for adaptive and synchronous endpoints, but we didn't take care of the max frame size for those pre-calculated values. When a device or a bus limits the packet size, a high sample rate or a high number of channels may lead to the packet sizes that are larger than the given limit, which results in an error from the USB core at submitting URBs. As a simple workaround, just add the sanity checks of pre-calculated packet sizes to have the upper boundary of ep->maxframesize. Fixes: f0bd62b ("ALSA: usb-audio: Improve frames size computation") Link: https://bugzilla.kernel.org/show_bug.cgi?id=221076 Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20260225085233.316306-2-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 9aa3e33 commit de45fb5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sound/usb/endpoint.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,9 @@ int snd_usb_endpoint_set_params(struct snd_usb_audio *chip,
13741374
return -EINVAL;
13751375
}
13761376

1377+
ep->packsize[0] = min(ep->packsize[0], ep->maxframesize);
1378+
ep->packsize[1] = min(ep->packsize[1], ep->maxframesize);
1379+
13771380
/* calculate the frequency in 16.16 format */
13781381
ep->freqm = ep->freqn;
13791382
ep->freqshift = INT_MIN;

0 commit comments

Comments
 (0)