@@ -627,16 +627,14 @@ static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip,
627
627
*/
628
628
static void *
629
629
snd_usb_find_input_terminal_descriptor (struct usb_host_interface * ctrl_iface ,
630
- int terminal_id , bool uac23 )
630
+ int terminal_id , int protocol )
631
631
{
632
632
struct uac2_input_terminal_descriptor * term = NULL ;
633
- size_t minlen = uac23 ? sizeof (struct uac2_input_terminal_descriptor ) :
634
- sizeof (struct uac_input_terminal_descriptor );
635
633
636
634
while ((term = snd_usb_find_csint_desc (ctrl_iface -> extra ,
637
635
ctrl_iface -> extralen ,
638
636
term , UAC_INPUT_TERMINAL ))) {
639
- if (term -> bLength < minlen )
637
+ if (! snd_usb_validate_audio_desc ( term , protocol ) )
640
638
continue ;
641
639
if (term -> bTerminalID == terminal_id )
642
640
return term ;
@@ -647,16 +645,17 @@ snd_usb_find_input_terminal_descriptor(struct usb_host_interface *ctrl_iface,
647
645
648
646
static void *
649
647
snd_usb_find_output_terminal_descriptor (struct usb_host_interface * ctrl_iface ,
650
- int terminal_id )
648
+ int terminal_id , int protocol )
651
649
{
652
650
/* OK to use with both UAC2 and UAC3 */
653
651
struct uac2_output_terminal_descriptor * term = NULL ;
654
652
655
653
while ((term = snd_usb_find_csint_desc (ctrl_iface -> extra ,
656
654
ctrl_iface -> extralen ,
657
655
term , UAC_OUTPUT_TERMINAL ))) {
658
- if (term -> bLength >= sizeof (* term ) &&
659
- term -> bTerminalID == terminal_id )
656
+ if (!snd_usb_validate_audio_desc (term , protocol ))
657
+ continue ;
658
+ if (term -> bTerminalID == terminal_id )
660
659
return term ;
661
660
}
662
661
@@ -731,7 +730,7 @@ snd_usb_get_audioformat_uac12(struct snd_usb_audio *chip,
731
730
732
731
iterm = snd_usb_find_input_terminal_descriptor (chip -> ctrl_intf ,
733
732
as -> bTerminalLink ,
734
- false );
733
+ protocol );
735
734
if (iterm ) {
736
735
num_channels = iterm -> bNrChannels ;
737
736
chconfig = le16_to_cpu (iterm -> wChannelConfig );
@@ -767,7 +766,7 @@ snd_usb_get_audioformat_uac12(struct snd_usb_audio *chip,
767
766
*/
768
767
input_term = snd_usb_find_input_terminal_descriptor (chip -> ctrl_intf ,
769
768
as -> bTerminalLink ,
770
- true );
769
+ protocol );
771
770
if (input_term ) {
772
771
clock = input_term -> bCSourceID ;
773
772
if (!chconfig && (num_channels == input_term -> bNrChannels ))
@@ -776,7 +775,8 @@ snd_usb_get_audioformat_uac12(struct snd_usb_audio *chip,
776
775
}
777
776
778
777
output_term = snd_usb_find_output_terminal_descriptor (chip -> ctrl_intf ,
779
- as -> bTerminalLink );
778
+ as -> bTerminalLink ,
779
+ protocol );
780
780
if (output_term ) {
781
781
clock = output_term -> bCSourceID ;
782
782
goto found_clock ;
@@ -1002,14 +1002,15 @@ snd_usb_get_audioformat_uac3(struct snd_usb_audio *chip,
1002
1002
*/
1003
1003
input_term = snd_usb_find_input_terminal_descriptor (chip -> ctrl_intf ,
1004
1004
as -> bTerminalLink ,
1005
- true );
1005
+ UAC_VERSION_3 );
1006
1006
if (input_term ) {
1007
1007
clock = input_term -> bCSourceID ;
1008
1008
goto found_clock ;
1009
1009
}
1010
1010
1011
1011
output_term = snd_usb_find_output_terminal_descriptor (chip -> ctrl_intf ,
1012
- as -> bTerminalLink );
1012
+ as -> bTerminalLink ,
1013
+ UAC_VERSION_3 );
1013
1014
if (output_term ) {
1014
1015
clock = output_term -> bCSourceID ;
1015
1016
goto found_clock ;
0 commit comments