From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753783Ab2DMFiQ (ORCPT ); Fri, 13 Apr 2012 01:38:16 -0400 Received: from cantor2.suse.de ([195.135.220.15]:47524 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753064Ab2DMFiO (ORCPT ); Fri, 13 Apr 2012 01:38:14 -0400 Date: Fri, 13 Apr 2012 07:38:10 +0200 Message-ID: From: Takashi Iwai To: Jesper Juhl Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Jaroslav Kysela , David Henningsson , Kailang Yang , PeiSen Hou , Jonathan Woithe Subject: Re: [PATCH] ALSA: hda/realtek - Fix mem leak (and rid us of trailing whitespace). In-Reply-To: References: User-Agent: Wanderlust/2.15.6 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.7 Emacs/23.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At Thu, 12 Apr 2012 22:11:25 +0200 (CEST), Jesper Juhl wrote: > > 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: Jesper Juhl Thanks, applied now. Takashi > --- > sound/pci/hda/patch_realtek.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) > > diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c > index 9917e55..c5e1a1a 100644 > --- a/sound/pci/hda/patch_realtek.c > +++ b/sound/pci/hda/patch_realtek.c > @@ -3398,8 +3398,10 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec) > for (;;) { > badness = fill_and_eval_dacs(codec, fill_hardwired, > fill_mio_first); > - if (badness < 0) > + if (badness < 0) { > + kfree(best_cfg); > return badness; > + } > debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n", > cfg->line_out_type, fill_hardwired, fill_mio_first, > badness); > @@ -3434,7 +3436,7 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec) > cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; > fill_hardwired = true; > continue; > - } > + } > if (cfg->hp_outs > 0 && > cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { > cfg->speaker_outs = cfg->line_outs; > @@ -3448,7 +3450,7 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec) > cfg->line_out_type = AUTO_PIN_HP_OUT; > fill_hardwired = true; > continue; > - } > + } > break; > } > > @@ -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 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); > } > > @@ -6079,7 +6081,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { > * Basically the device should work as is without the fixup table. > * If BIOS doesn't give a proper info, enable the corresponding > * fixup entry. > - */ > + */ > SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", > ALC269_FIXUP_AMIC), > SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), > @@ -6296,7 +6298,7 @@ static void alc_fixup_no_jack_detect(struct hda_codec *codec, > { > if (action == ALC_FIXUP_ACT_PRE_PROBE) > codec->no_jack_detect = 1; > -} > +} > > static const struct alc_fixup alc861_fixups[] = { > [ALC861_FIXUP_FSC_AMILO_PI1505] = { > @@ -6714,7 +6716,7 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = { > * Basically the device should work as is without the fixup table. > * If BIOS doesn't give a proper info, enable the corresponding > * fixup entry. > - */ > + */ > 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, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), > -- > 1.7.10 > > > -- > Jesper Juhl http://www.chaosbits.net/ > Don't top-post http://www.catb.org/jargon/html/T/top-post.html > Plain text mails only, please. > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH] ALSA: hda/realtek - Fix mem leak (and rid us of trailing whitespace). Date: Fri, 13 Apr 2012 07:38:10 +0200 Message-ID: References: Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 29EF710B8C0 for ; Fri, 13 Apr 2012 07:38:14 +0200 (CEST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Jesper Juhl Cc: alsa-devel@alsa-project.org, Kailang Yang , linux-kernel@vger.kernel.org, PeiSen Hou , Jonathan Woithe , David Henningsson List-Id: alsa-devel@alsa-project.org At Thu, 12 Apr 2012 22:11:25 +0200 (CEST), Jesper Juhl wrote: > > 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: Jesper Juhl Thanks, applied now. Takashi > --- > sound/pci/hda/patch_realtek.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) > > diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c > index 9917e55..c5e1a1a 100644 > --- a/sound/pci/hda/patch_realtek.c > +++ b/sound/pci/hda/patch_realtek.c > @@ -3398,8 +3398,10 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec) > for (;;) { > badness = fill_and_eval_dacs(codec, fill_hardwired, > fill_mio_first); > - if (badness < 0) > + if (badness < 0) { > + kfree(best_cfg); > return badness; > + } > debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n", > cfg->line_out_type, fill_hardwired, fill_mio_first, > badness); > @@ -3434,7 +3436,7 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec) > cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; > fill_hardwired = true; > continue; > - } > + } > if (cfg->hp_outs > 0 && > cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { > cfg->speaker_outs = cfg->line_outs; > @@ -3448,7 +3450,7 @@ static int alc_auto_fill_dac_nids(struct hda_codec *codec) > cfg->line_out_type = AUTO_PIN_HP_OUT; > fill_hardwired = true; > continue; > - } > + } > break; > } > > @@ -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 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); > } > > @@ -6079,7 +6081,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { > * Basically the device should work as is without the fixup table. > * If BIOS doesn't give a proper info, enable the corresponding > * fixup entry. > - */ > + */ > SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", > ALC269_FIXUP_AMIC), > SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), > @@ -6296,7 +6298,7 @@ static void alc_fixup_no_jack_detect(struct hda_codec *codec, > { > if (action == ALC_FIXUP_ACT_PRE_PROBE) > codec->no_jack_detect = 1; > -} > +} > > static const struct alc_fixup alc861_fixups[] = { > [ALC861_FIXUP_FSC_AMILO_PI1505] = { > @@ -6714,7 +6716,7 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = { > * Basically the device should work as is without the fixup table. > * If BIOS doesn't give a proper info, enable the corresponding > * fixup entry. > - */ > + */ > 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, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), > -- > 1.7.10 > > > -- > Jesper Juhl http://www.chaosbits.net/ > Don't top-post http://www.catb.org/jargon/html/T/top-post.html > Plain text mails only, please. >