Skip to contentSkip to conversation

ALSA: hda: fix possible null dereference

PATCH Applied Sudip Mukherjee 2 participants 2 messages Apr 2, 2015 – Apr 4, 2015 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 sound/pci/hda/hda_codec.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
sound/pci/hda/hda_codec.c +2 -3
index 145cae7..7df18e2 100644
@@ -3717,9 +3717,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,
Signature · 1 line
1.8.1.2
Applied
#1 lore raw

At Thu, 2 Apr 2015 16:51:43 +0530,

Quoted 5 lines · Sudip Mukherjee

we are dereferencing pcm first then checking pcm. instead now lets put them in same if condition so that pcm is checked first.

Applied, thanks.

Takashi

Quoted 23 lines
---
 sound/pci/hda/hda_codec.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
sound/pci/hda/hda_codec.c +2 -3
index 145cae7..7df18e2 100644
@@ -3717,9 +3717,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,
Signature · 1 line
1.8.1.2