Skip to content

Commit 92a9c0a

Browse files
perexgtiwai
authored andcommitted
ALSA: usb-audio: Fix possible NULL pointer dereference in snd_usb_pcm_has_fixed_rate()
The subs function argument may be NULL, so do not use it before the NULL check. Fixes: 291e9da ("ALSA: usb-audio: Always initialize fixed_rate in snd_usb_find_implicit_fb_sync_format()") Reported-by: coverity-bot <[email protected]> Link: https://lore.kernel.org/alsa-devel/202301121424.4A79A485@keescook/ Signed-off-by: Jaroslav Kysela <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 84aa305 commit 92a9c0a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sound/usb/pcm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,12 @@ find_substream_format(struct snd_usb_substream *subs,
160160
bool snd_usb_pcm_has_fixed_rate(struct snd_usb_substream *subs)
161161
{
162162
const struct audioformat *fp;
163-
struct snd_usb_audio *chip = subs->stream->chip;
163+
struct snd_usb_audio *chip;
164164
int rate = -1;
165165

166166
if (!subs)
167167
return false;
168+
chip = subs->stream->chip;
168169
if (!(chip->quirk_flags & QUIRK_FLAG_FIXED_RATE))
169170
return false;
170171
list_for_each_entry(fp, &subs->fmt_list, list) {

0 commit comments

Comments
 (0)