From: Eldad Zack Date: Sat, 3 Aug 2013 08:51:15 +0000 (+0200) Subject: ALSA: usb-audio: WARN_ON when alts is passed as NULL X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e7e58df8ef3c9edb09a240084b4e0523c12bcb71;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git ALSA: usb-audio: WARN_ON when alts is passed as NULL Prevent NULL dereference in snd_usb_add_endpoints(), when alts is passed as NULL. In this case, WARN (since this is a non-fatal bug) and return NULL ep. Call sites treat a NULL return value as an error. Signed-off-by: Eldad Zack Signed-off-by: Takashi Iwai --- diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c index 7a444b5501d9..92ea945ff486 100644 --- a/sound/usb/endpoint.c +++ b/sound/usb/endpoint.c @@ -418,6 +418,9 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip, struct snd_usb_endpoint *ep; int is_playback = direction == SNDRV_PCM_STREAM_PLAYBACK; + if (WARN_ON(!alts)) + return NULL; + mutex_lock(&chip->mutex); list_for_each_entry(ep, &chip->ep_list, list) {