Skip to content

Commit

Permalink
ALSA: hda - Fix memory leaks in conexant jack arrays
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Takashi Iwai committed Feb 2, 2011
1 parent 6abb319 commit 70f7db1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sound/pci/hda/patch_conexant.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,16 @@ static int conexant_add_jack(struct hda_codec *codec,
struct conexant_spec *spec;
struct conexant_jack *jack;
const char *name;
int err;
int i, err;

spec = codec->spec;
snd_array_init(&spec->jacks, sizeof(*jack), 32);

jack = spec->jacks.list;
for (i = 0; i < spec->jacks.used; i++, jack++)
if (jack->nid == nid)
return 0 ; /* already present */

jack = snd_array_new(&spec->jacks);
name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;

Expand Down

0 comments on commit 70f7db1

Please sign in to comment.