aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-02-02 11:16:38 -0500
committerTakashi Iwai <tiwai@suse.de>2011-02-02 11:16:38 -0500
commit70f7db11c45a313b23922cacf248c613c3b2144c (patch)
treed7d5b6bab9d76f15b7539cb9147d76a338db42ec /sound
parent6abb31908f3ed7d38e93d06b704c9342029ca9a0 (diff)
ALSA: hda - Fix memory leaks in conexant jack arrays
The Conexant codec driver adds the jack arrays in init callback which may be called also in each PM resume. This results in the addition of new jack element at each time. The fix is to check whether the requested jack is already present in the array. Reference: Novell bug 668929 https://bugzilla.novell.com/show_bug.cgi?id=668929 Cc: <stable@kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/hda/patch_conexant.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 7e1ca43bd660..fbe97d32140d 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -407,10 +407,16 @@ static int conexant_add_jack(struct hda_codec *codec,
407 struct conexant_spec *spec; 407 struct conexant_spec *spec;
408 struct conexant_jack *jack; 408 struct conexant_jack *jack;
409 const char *name; 409 const char *name;
410 int err; 410 int i, err;
411 411
412 spec = codec->spec; 412 spec = codec->spec;
413 snd_array_init(&spec->jacks, sizeof(*jack), 32); 413 snd_array_init(&spec->jacks, sizeof(*jack), 32);
414
415 jack = spec->jacks.list;
416 for (i = 0; i < spec->jacks.used; i++, jack++)
417 if (jack->nid == nid)
418 return 0 ; /* already present */
419
414 jack = snd_array_new(&spec->jacks); 420 jack = snd_array_new(&spec->jacks);
415 name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ; 421 name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
416 422