Commit 7d7eb9ea authored by Jesper Juhl's avatar Jesper Juhl Committed by Takashi Iwai

ALSA: hda/realtek - Fix mem leak (and rid us of trailing whitespace).

In sound/pci/hda/patch_realtek.c::alc_auto_fill_dac_nids(), in the
'for (;;)' loop, if the 'badness' value returned from
fill_and_eval_dacs() is negative, then we'll return from the function
without freeing the memory we allocated for 'best_cfg', thus leaking.
Fix the leak by kfree()'ing the memory when badness is negative.

While I was there I also noticed some trailing whitespace in the
function that I removed (along with all other trailing whitespace in
the file) - it didn't seem worth-while to do that as two patches, so I
hope it's OK that I just did it all as one patch.
Signed-off-by: default avatarJesper Juhl <jj@chaosbits.net>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 29ebe402
...@@ -3398,8 +3398,10 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec) ...@@ -3398,8 +3398,10 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec)
for (;;) { for (;;) {
badness = fill_and_eval_dacs(codec, fill_hardwired, badness = fill_and_eval_dacs(codec, fill_hardwired,
fill_mio_first); fill_mio_first);
if (badness < 0) if (badness < 0) {
kfree(best_cfg);
return badness; return badness;
}
debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n", debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n",
cfg->line_out_type, fill_hardwired, fill_mio_first, cfg->line_out_type, fill_hardwired, fill_mio_first,
badness); badness);
...@@ -3434,7 +3436,7 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec) ...@@ -3434,7 +3436,7 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec)
cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; cfg->line_out_type = AUTO_PIN_SPEAKER_OUT;
fill_hardwired = true; fill_hardwired = true;
continue; continue;
} }
if (cfg->hp_outs > 0 && if (cfg->hp_outs > 0 &&
cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
cfg->speaker_outs = cfg->line_outs; cfg->speaker_outs = cfg->line_outs;
...@@ -3448,7 +3450,7 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec) ...@@ -3448,7 +3450,7 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec)
cfg->line_out_type = AUTO_PIN_HP_OUT; cfg->line_out_type = AUTO_PIN_HP_OUT;
fill_hardwired = true; fill_hardwired = true;
continue; continue;
} }
break; break;
} }
...@@ -4423,7 +4425,7 @@ static int alc_parse_auto_config(struct hda_codec *codec, ...@@ -4423,7 +4425,7 @@ static int alc_parse_auto_config(struct hda_codec *codec,
static int alc880_parse_auto_config(struct hda_codec *codec) static int alc880_parse_auto_config(struct hda_codec *codec)
{ {
static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 }; static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids); return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
} }
...@@ -6093,7 +6095,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { ...@@ -6093,7 +6095,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
* Basically the device should work as is without the fixup table. * Basically the device should work as is without the fixup table.
* If BIOS doesn't give a proper info, enable the corresponding * If BIOS doesn't give a proper info, enable the corresponding
* fixup entry. * fixup entry.
*/ */
SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
ALC269_FIXUP_AMIC), ALC269_FIXUP_AMIC),
SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
...@@ -6310,7 +6312,7 @@ static void alc_fixup_no_jack_detect(struct hda_codec *codec, ...@@ -6310,7 +6312,7 @@ static void alc_fixup_no_jack_detect(struct hda_codec *codec,
{ {
if (action == ALC_FIXUP_ACT_PRE_PROBE) if (action == ALC_FIXUP_ACT_PRE_PROBE)
codec->no_jack_detect = 1; codec->no_jack_detect = 1;
} }
static const struct alc_fixup alc861_fixups[] = { static const struct alc_fixup alc861_fixups[] = {
[ALC861_FIXUP_FSC_AMILO_PI1505] = { [ALC861_FIXUP_FSC_AMILO_PI1505] = {
...@@ -6728,7 +6730,7 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = { ...@@ -6728,7 +6730,7 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = {
* Basically the device should work as is without the fixup table. * Basically the device should work as is without the fixup table.
* If BIOS doesn't give a proper info, enable the corresponding * If BIOS doesn't give a proper info, enable the corresponding
* fixup entry. * fixup entry.
*/ */
SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1), SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3), SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment