From: Sudip Mukherjee Date: Thu, 2 Apr 2015 11:21:43 +0000 (+0530) Subject: ALSA: hda: fix possible null dereference X-Git-Tag: v4.1-rc1~117^2~6^2~25 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=751e2216899cb143fe1d5909fe762870faa945f6;p=linux.git ALSA: hda: fix possible null dereference we are dereferencing pcm first then checking pcm. instead now lets put them in same if condition so that pcm is checked first. Signed-off-by: Sudip Mukherjee Signed-off-by: Takashi Iwai --- diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 41851f9b48c1..16dfa1ed10dd 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -3230,9 +3230,8 @@ static int add_std_chmaps(struct hda_codec *codec) struct snd_pcm_chmap *chmap; const struct snd_pcm_chmap_elem *elem; - if (pcm->own_chmap) - continue; - if (!pcm || !hinfo->substreams) + if (!pcm || pcm->own_chmap || + !hinfo->substreams) continue; elem = hinfo->chmap ? hinfo->chmap : snd_pcm_std_chmaps; err = snd_pcm_add_chmap_ctls(pcm->pcm, str, elem,