aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Hovold <[email protected]>2019-12-20 10:31:34 +0100
committerTakashi Iwai <[email protected]>2019-12-20 11:31:46 +0100
commit0141254b0a74b37aa7eb13d42a56adba84d51c73 (patch)
tree1095e51d158b7daa9faa3bc6080d22feff6ffd03
parent66c5d718e5a6f80153b5e8d6ad8ba8e9c3320839 (diff)
ALSA: usb-audio: fix set_format altsetting sanity check
Make sure to check the return value of usb_altnum_to_altsetting() to avoid dereferencing a NULL pointer when the requested alternate settings is missing. The format altsetting number may come from a quirk table and there does not seem to be any other validation of it (the corresponding index is checked however). Fixes: b099b9693d23 ("ALSA: usb-audio: Avoid superfluous usb_set_interface() calls") Cc: stable <[email protected]> # 4.18 Signed-off-by: Johan Hovold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
-rw-r--r--sound/usb/pcm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 96298c767c76..a11c8150af58 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -506,9 +506,9 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
if (WARN_ON(!iface))
return -EINVAL;
alts = usb_altnum_to_altsetting(iface, fmt->altsetting);
- altsd = get_iface_desc(alts);
- if (WARN_ON(altsd->bAlternateSetting != fmt->altsetting))
+ if (WARN_ON(!alts))
return -EINVAL;
+ altsd = get_iface_desc(alts);
if (fmt == subs->cur_audiofmt && !subs->need_setup_fmt)
return 0;