aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2009-10-17 02:33:47 -0400
committerTakashi Iwai <tiwai@suse.de>2009-10-30 07:01:38 -0400
commite8e0929d7290cab7c5b1a3e5f5f54f73daf38038 (patch)
tree164f1377ab4210212b61ce65fa5b16a0cf82b765 /sound
parent4b3be6afa4ab8b3fdce39df68bad71f8b85164de (diff)
ALSA: sound/parisc: Move dereference after NULL test
If the NULL test on h is needed in snd_harmony_mixer_init, then the dereference should be after the NULL test. Actually, there is a sequence of calls: snd_harmony_create, then snd_harmony_pcm_init, and then snd_harmony_mixer_init. snd_harmony_create initializes h, but may indeed leave it as NULL. There was no NULL test at the beginning of snd_harmony_pcm_init, so I have added one. The NULL test in snd_harmony_mixer_init is then not necessary, but in case the ordering of the calls changes, I have left it, and moved the dereference after it. A simplified version of the semantic match that detects this problem is as follows (http://coccinelle.lip6.fr/): // <smpl> @match exists@ expression x, E; identifier fld; @@ * x->fld ... when != \(x = E\|&x\) * x == NULL // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/parisc/harmony.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c
index e924492df21d..f47f9e226b08 100644
--- a/sound/parisc/harmony.c
+++ b/sound/parisc/harmony.c
@@ -624,6 +624,9 @@ snd_harmony_pcm_init(struct snd_harmony *h)
624 struct snd_pcm *pcm; 624 struct snd_pcm *pcm;
625 int err; 625 int err;
626 626
627 if (snd_BUG_ON(!h))
628 return -EINVAL;
629
627 harmony_disable_interrupts(h); 630 harmony_disable_interrupts(h);
628 631
629 err = snd_pcm_new(h->card, "harmony", 0, 1, 1, &pcm); 632 err = snd_pcm_new(h->card, "harmony", 0, 1, 1, &pcm);
@@ -865,11 +868,12 @@ snd_harmony_mixer_reset(struct snd_harmony *h)
865static int __devinit 868static int __devinit
866snd_harmony_mixer_init(struct snd_harmony *h) 869snd_harmony_mixer_init(struct snd_harmony *h)
867{ 870{
868 struct snd_card *card = h->card; 871 struct snd_card *card;
869 int idx, err; 872 int idx, err;
870 873
871 if (snd_BUG_ON(!h)) 874 if (snd_BUG_ON(!h))
872 return -EINVAL; 875 return -EINVAL;
876 card = h->card;
873 strcpy(card->mixername, "Harmony Gain control interface"); 877 strcpy(card->mixername, "Harmony Gain control interface");
874 878
875 for (idx = 0; idx < HARMONY_CONTROLS; idx++) { 879 for (idx = 0; idx < HARMONY_CONTROLS; idx++) {