summaryrefslogtreecommitdiffstats
path: root/sound/usb/clock.c
diff options
context:
space:
mode:
authorChengfeng Ye <cyeaa@connect.ust.hk>2021-10-24 13:17:36 +0200
committerTakashi Iwai <tiwai@suse.de>2021-10-26 08:05:23 +0200
commitb97053df0f04747c3c1e021ecbe99db675342954 (patch)
treedc5a4a5a4562a0c2bf896596860b10945fdba7c6 /sound/usb/clock.c
parentALSA: gus: fix null pointer dereference on pointer block (diff)
downloadlinux-b97053df0f04747c3c1e021ecbe99db675342954.tar.xz
linux-b97053df0f04747c3c1e021ecbe99db675342954.zip
ALSA: usb-audio: fix null pointer dereference on pointer cs_desc
The pointer cs_desc return from snd_usb_find_clock_source could be null, so there is a potential null pointer dereference issue. Fix this by adding a null check before dereference. Signed-off-by: Chengfeng Ye <cyeaa@connect.ust.hk> Link: https://lore.kernel.org/r/20211024111736.11342-1-cyeaa@connect.ust.hk Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/clock.c')
-rw-r--r--sound/usb/clock.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sound/usb/clock.c b/sound/usb/clock.c
index 7dd71d342443..4dfe76416794 100644
--- a/sound/usb/clock.c
+++ b/sound/usb/clock.c
@@ -496,6 +496,10 @@ int snd_usb_set_sample_rate_v2v3(struct snd_usb_audio *chip,
union uac23_clock_source_desc *cs_desc;
cs_desc = snd_usb_find_clock_source(chip, clock, fmt->protocol);
+
+ if (!cs_desc)
+ return 0;
+
if (fmt->protocol == UAC_VERSION_3)
bmControls = le32_to_cpu(cs_desc->v3.bmControls);
else