aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <takashi.iwai@gmail.com>2006-03-06 18:42:51 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-06 21:40:44 -0500
commit2fbf182ed00a71c35e53329c2010df2baf8a89c6 (patch)
tree5b66a27b68a28b3b9f7e308519cc72315e69f4e7 /sound/core
parent5aee405c662ca644980c184774277fc6d0769a84 (diff)
[PATCH] alsa: fix error paths in snd_ctl_elem_add()
Fix bugs in error paths of snd_ctl_elem_add() - NULL reference - double free (already freed in snd_ctl_add()) Signed-off-by: Takashi Iwai <tiwai@suse.de> Cc: Jaroslav Kysela <perex@suse.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/control.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/sound/core/control.c b/sound/core/control.c
index abd62f943726..0c29679a8576 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -959,17 +959,15 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,
959 kctl.private_free = snd_ctl_elem_user_free; 959 kctl.private_free = snd_ctl_elem_user_free;
960 _kctl = snd_ctl_new(&kctl, access); 960 _kctl = snd_ctl_new(&kctl, access);
961 if (_kctl == NULL) { 961 if (_kctl == NULL) {
962 kfree(_kctl->private_data); 962 kfree(ue);
963 return -ENOMEM; 963 return -ENOMEM;
964 } 964 }
965 _kctl->private_data = ue; 965 _kctl->private_data = ue;
966 for (idx = 0; idx < _kctl->count; idx++) 966 for (idx = 0; idx < _kctl->count; idx++)
967 _kctl->vd[idx].owner = file; 967 _kctl->vd[idx].owner = file;
968 err = snd_ctl_add(card, _kctl); 968 err = snd_ctl_add(card, _kctl);
969 if (err < 0) { 969 if (err < 0)
970 snd_ctl_free_one(_kctl);
971 return err; 970 return err;
972 }
973 971
974 down_write(&card->controls_rwsem); 972 down_write(&card->controls_rwsem);
975 card->user_ctl_count++; 973 card->user_ctl_count++;