Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ee48df57 authored by Takashi Iwai's avatar Takashi Iwai
Browse files

ALSA: hda - Fix memory leaks in Realtek & Conexant codec parsers



When moved to the helper code, forgot to release the verb arrays.

Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent befae82e
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -618,7 +618,6 @@ int snd_hda_gen_add_verbs(struct hda_gen_spec *spec,
			  const struct hda_verb *list)
			  const struct hda_verb *list)
{
{
	const struct hda_verb **v;
	const struct hda_verb **v;
	snd_array_init(&spec->verbs, sizeof(struct hda_verb *), 8);
	v = snd_array_new(&spec->verbs);
	v = snd_array_new(&spec->verbs);
	if (!v)
	if (!v)
		return -ENOMEM;
		return -ENOMEM;
+10 −0
Original line number Original line Diff line number Diff line
@@ -157,4 +157,14 @@ void snd_hda_pick_fixup(struct hda_codec *codec,
			const struct snd_pci_quirk *quirk,
			const struct snd_pci_quirk *quirk,
			const struct hda_fixup *fixlist);
			const struct hda_fixup *fixlist);


static inline void snd_hda_gen_init(struct hda_gen_spec *spec)
{
	snd_array_init(&spec->verbs, sizeof(struct hda_verb *), 8);
}

static inline void snd_hda_gen_free(struct hda_gen_spec *spec)
{
	snd_array_free(&spec->verbs);
}

#endif /* __SOUND_HDA_AUTO_PARSER_H */
#endif /* __SOUND_HDA_AUTO_PARSER_H */
+4 −1
Original line number Original line Diff line number Diff line
@@ -445,8 +445,10 @@ static int conexant_init(struct hda_codec *codec)


static void conexant_free(struct hda_codec *codec)
static void conexant_free(struct hda_codec *codec)
{
{
	struct conexant_spec *spec = codec->spec;
	snd_hda_gen_free(&spec->gen);
	snd_hda_detach_beep_device(codec);
	snd_hda_detach_beep_device(codec);
	kfree(codec->spec);
	kfree(spec);
}
}


static const struct snd_kcontrol_new cxt_capture_mixers[] = {
static const struct snd_kcontrol_new cxt_capture_mixers[] = {
@@ -4498,6 +4500,7 @@ static int patch_conexant_auto(struct hda_codec *codec)
	if (!spec)
	if (!spec)
		return -ENOMEM;
		return -ENOMEM;
	codec->spec = spec;
	codec->spec = spec;
	snd_hda_gen_init(&spec->gen);


	switch (codec->vendor_id) {
	switch (codec->vendor_id) {
	case 0x14f15045:
	case 0x14f15045:
+2 −0
Original line number Original line Diff line number Diff line
@@ -2289,6 +2289,7 @@ static void alc_free(struct hda_codec *codec)
	alc_shutup(codec);
	alc_shutup(codec);
	alc_free_kctls(codec);
	alc_free_kctls(codec);
	alc_free_bind_ctls(codec);
	alc_free_bind_ctls(codec);
	snd_hda_gen_free(&spec->gen);
	kfree(spec);
	kfree(spec);
	snd_hda_detach_beep_device(codec);
	snd_hda_detach_beep_device(codec);
}
}
@@ -4253,6 +4254,7 @@ static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
		return -ENOMEM;
		return -ENOMEM;
	codec->spec = spec;
	codec->spec = spec;
	spec->mixer_nid = mixer_nid;
	spec->mixer_nid = mixer_nid;
	snd_hda_gen_init(&spec->gen);


	err = alc_codec_rename_from_preset(codec);
	err = alc_codec_rename_from_preset(codec);
	if (err < 0) {
	if (err < 0) {