]> www.infradead.org Git - users/hch/misc.git/commitdiff
ALSA: usb-audio: Add validation of UAC2/UAC3 effect units
authorTakashi Iwai <tiwai@suse.de>
Thu, 21 Aug 2025 15:17:50 +0000 (17:17 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 21 Aug 2025 15:18:21 +0000 (17:18 +0200)
Just add fixed struct size validations for UAC2 and UAC3 effect
units.  The descriptor has a variable-length array, so it should be
validated with a proper function later once when the unit is really
parsed and used by the driver (currently only referred partially for
the input terminal parsing).

Link: https://patch.msgid.link/20250821151751.12100-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/validate.c

index a0d55b77c9941d4ba8739989dde1842aa23f6816..4bb4893f6e74f7d1677ec0b0a75c144d4b46962b 100644 (file)
@@ -266,7 +266,11 @@ static const struct usb_desc_validator audio_validators[] = {
        FUNC(UAC_VERSION_2, UAC_MIXER_UNIT, validate_mixer_unit),
        FUNC(UAC_VERSION_2, UAC_SELECTOR_UNIT, validate_selector_unit),
        FUNC(UAC_VERSION_2, UAC_FEATURE_UNIT, validate_uac2_feature_unit),
-       /* UAC_VERSION_2, UAC2_EFFECT_UNIT: not implemented yet */
+       /* just a stop-gap, it should be a proper function for the array
+        * once if the unit is really parsed/used
+        */
+       FIXED(UAC_VERSION_2, UAC2_EFFECT_UNIT,
+             struct uac2_effect_unit_descriptor),
        FUNC(UAC_VERSION_2, UAC2_PROCESSING_UNIT_V2, validate_processing_unit),
        FUNC(UAC_VERSION_2, UAC2_EXTENSION_UNIT_V2, validate_processing_unit),
        FIXED(UAC_VERSION_2, UAC2_CLOCK_SOURCE,
@@ -286,7 +290,8 @@ static const struct usb_desc_validator audio_validators[] = {
        FUNC(UAC_VERSION_3, UAC3_MIXER_UNIT, validate_mixer_unit),
        FUNC(UAC_VERSION_3, UAC3_SELECTOR_UNIT, validate_selector_unit),
        FUNC(UAC_VERSION_3, UAC3_FEATURE_UNIT, validate_uac3_feature_unit),
-       /*  UAC_VERSION_3, UAC3_EFFECT_UNIT: not implemented yet */
+       FIXED(UAC_VERSION_3, UAC3_EFFECT_UNIT,
+             struct uac2_effect_unit_descriptor), /* sharing the same struct */
        FUNC(UAC_VERSION_3, UAC3_PROCESSING_UNIT, validate_processing_unit),
        FUNC(UAC_VERSION_3, UAC3_EXTENSION_UNIT, validate_processing_unit),
        FIXED(UAC_VERSION_3, UAC3_CLOCK_SOURCE,