Commit f8e5f90b authored by Takashi Iwai's avatar Takashi Iwai

ALSA: usb-audio: Fix endianess in descriptor validation

I overlooked that some fields are words and need the converts from
LE in the recently added USB descriptor validation code.
This patch fixes those with the proper macro usages.

Fixes: 57f87706 ("ALSA: usb-audio: More validations of descriptor units")
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200201080530.22390-1-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 78be2228
...@@ -110,7 +110,7 @@ static bool validate_processing_unit(const void *p, ...@@ -110,7 +110,7 @@ static bool validate_processing_unit(const void *p,
default: default:
if (v->type == UAC1_EXTENSION_UNIT) if (v->type == UAC1_EXTENSION_UNIT)
return true; /* OK */ return true; /* OK */
switch (d->wProcessType) { switch (le16_to_cpu(d->wProcessType)) {
case UAC_PROCESS_UP_DOWNMIX: case UAC_PROCESS_UP_DOWNMIX:
case UAC_PROCESS_DOLBY_PROLOGIC: case UAC_PROCESS_DOLBY_PROLOGIC:
if (d->bLength < len + 1) /* bNrModes */ if (d->bLength < len + 1) /* bNrModes */
...@@ -125,7 +125,7 @@ static bool validate_processing_unit(const void *p, ...@@ -125,7 +125,7 @@ static bool validate_processing_unit(const void *p,
case UAC_VERSION_2: case UAC_VERSION_2:
if (v->type == UAC2_EXTENSION_UNIT_V2) if (v->type == UAC2_EXTENSION_UNIT_V2)
return true; /* OK */ return true; /* OK */
switch (d->wProcessType) { switch (le16_to_cpu(d->wProcessType)) {
case UAC2_PROCESS_UP_DOWNMIX: case UAC2_PROCESS_UP_DOWNMIX:
case UAC2_PROCESS_DOLBY_PROLOCIC: /* SiC! */ case UAC2_PROCESS_DOLBY_PROLOCIC: /* SiC! */
if (d->bLength < len + 1) /* bNrModes */ if (d->bLength < len + 1) /* bNrModes */
...@@ -142,7 +142,7 @@ static bool validate_processing_unit(const void *p, ...@@ -142,7 +142,7 @@ static bool validate_processing_unit(const void *p,
len += 2; /* wClusterDescrID */ len += 2; /* wClusterDescrID */
break; break;
} }
switch (d->wProcessType) { switch (le16_to_cpu(d->wProcessType)) {
case UAC3_PROCESS_UP_DOWNMIX: case UAC3_PROCESS_UP_DOWNMIX:
if (d->bLength < len + 1) /* bNrModes */ if (d->bLength < len + 1) /* bNrModes */
return false; return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment