sound/usb: fix null pointer dereference on pointer cs_desc
PATCH 1/1 sound/usb: 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.
--- sound/usb/clock.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/usb/clock.c +4 -0
@@ -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
Signature · 1 line
2.17.1
A message that is not in the archive (sent off-list or not yet received): TYCP286MB1188D80DA04A5EE1B96814B28A829@TYCP286MB1188.JPNP286.PROD.OUTLOOK.COM
Quoted 6 lines · YE Chengfeng
Hi,
I found another potential null-ptr-dereference problem in this file, and not sure whether it is true. I send this patch to you just for reference, thinks a lot if you could spare some time to look at it.
The Fixes tag doesn't look correct (the code before the refactoring also didn't have NULL checks), so applied without it now.
thanks,
Takashi
Quoted 44 lines
Thanks so much,
Chengfeng
------------------------------------------------------------------------------
发件人: YE Chengfeng <[email protected]>
发送时间: 2021年10月24日 19:17
收件人: [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
抄送: [email protected] <[email protected]>; [email protected] <[email protected]>; YE Chengfeng <[email protected]>
主题: [PATCH]sound/usb: fix null pointer dereference on pointercs_descThe pointer
cs_descreturn fromsnd_usb_find_clock_sourcecould be null, so there is a potential null pointer dereference issue. Fix this by adding a null check before dereference.Fixes 9ec73005 ("ALSA: usb-audio: Refactoring UAC2/3 clock setup code")Signed-off-by Chengfeng Ye <[email protected]>--- sound/usb/clock.c | 4 ++++ 1 file changed, 4 insertions(+)sound/usb/clock.c +4
-0@@ -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
--
2.17.1
Got it.
Thanks so much.
-Chengfeng
-----邮件原件-----
发件人: Takashi Iwai <[email protected]>
发送时间: 2021年10月26日 14:11
收件人: YE Chengfeng <[email protected]>
抄送: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected] 主题: Re: 回复: [PATCH] sound/usb: fix null pointer dereference on pointer cs_desc
Quoted 6 lines · YE Chengfeng
Hi,
I found another potential null-ptr-dereference problem in this file, and not sure whether it is true. I send this patch to you just for reference, thinks a lot if you could spare some time to look at it.
The Fixes tag doesn't look correct (the code before the refactoring also didn't have NULL checks), so applied without it now.
thanks,
Takashi
Quoted 47 lines
Thanks so much,
Chengfeng
----------------------------------------------------------------------
--------
发件人: YE Chengfeng <[email protected]>
发送时间: 2021年10月24日 19:17
收件人: [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
抄送: [email protected] <[email protected]>; [email protected] <[email protected]>; YE Chengfeng <[email protected]>
主题: [PATCH]sound/usb: fix null pointer dereference on pointercs_descThe pointer
cs_descreturn fromsnd_usb_find_clock_sourcecould be null, so there is a potential null pointer dereference issue. Fix this by adding a null check before dereference.Fixes 9ec73005 ("ALSA: usb-audio: Refactoring UAC2/3 clock setupcode")
Signed-off-by Chengfeng Ye <[email protected]>--- sound/usb/clock.c | 4 ++++ 1 file changed, 4 insertions(+)sound/usb/clock.c index renamed from sound/usb/clock.c +0
-0
81d5ce07d548..98345a695dcc100644sound/usb/clock.c +4
-0@@ -496,6 +496,10 @@ int snd_usb_set_sample_rate_v2v3(structsnd_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--
2.17.1