Skip to content

Commit f1862db

Browse files
suunjgregkh
authored andcommitted
sound: ua101: fix division by zero at probe
commit d1f73f1 upstream. Add a missing sanity check for bNrChannels in detect_usb_format() to prevent a division by zero in playback_urb_complete() and capture_urb_complete(). USB core does not validate class-specific descriptor fields such as bNrChannels, so drivers must verify them before use. If a device provides bNrChannels = 0, frame_bytes becomes zero and is later used as a divisor in the URB completion handlers, leading to a kernel crash. Fixes: 63978ab ("sound: add Edirol UA-101 support") Cc: stable@vger.kernel.org Signed-off-by: SeungJu Cheon <suunj1331@gmail.com> Link: https://patch.msgid.link/20260426111239.103296-1-suunj1331@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3756043 commit f1862db

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

sound/usb/misc/ua101.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,13 @@ static int detect_usb_format(struct ua101 *ua)
974974

975975
ua->capture.channels = fmt_capture->bNrChannels;
976976
ua->playback.channels = fmt_playback->bNrChannels;
977+
if (!ua->capture.channels || !ua->playback.channels) {
978+
dev_err(&ua->dev->dev,
979+
"invalid channel count: capture %u, playback %u\n",
980+
ua->capture.channels, ua->playback.channels);
981+
return -EINVAL;
982+
}
983+
977984
ua->capture.frame_bytes =
978985
fmt_capture->bSubframeSize * ua->capture.channels;
979986
ua->playback.frame_bytes =

0 commit comments

Comments
 (0)