* [PATCH] ALSA: hda/realtek - Fix mem leak (and rid us of trailing whitespace).
@ 2012-04-12 20:11 ` Jesper Juhl
0 siblings, 0 replies; 4+ messages in thread
From: Jesper Juhl @ 2012-04-12 20:11 UTC (permalink / raw)
To: linux-kernel
Cc: alsa-devel, Jaroslav Kysela, Takashi Iwai, David Henningsson,
Kailang Yang, PeiSen Hou, Jonathan Woithe
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 <jj@chaosbits.net>
---
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 <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ALSA: hda/realtek - Fix mem leak (and rid us of trailing whitespace).
@ 2012-04-12 20:11 ` Jesper Juhl
0 siblings, 0 replies; 4+ messages in thread
From: Jesper Juhl @ 2012-04-12 20:11 UTC (permalink / raw)
To: linux-kernel
Cc: alsa-devel, Takashi Iwai, Kailang Yang, PeiSen Hou,
Jonathan Woithe, David Henningsson
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 <jj@chaosbits.net>
---
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 <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ALSA: hda/realtek - Fix mem leak (and rid us of trailing whitespace).
2012-04-12 20:11 ` Jesper Juhl
@ 2012-04-13 5:38 ` Takashi Iwai
-1 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2012-04-13 5:38 UTC (permalink / raw)
To: Jesper Juhl
Cc: linux-kernel, alsa-devel, Jaroslav Kysela, David Henningsson,
Kailang Yang, PeiSen Hou, Jonathan Woithe
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 <jj@chaosbits.net>
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 <jj@chaosbits.net> http://www.chaosbits.net/
> Don't top-post http://www.catb.org/jargon/html/T/top-post.html
> Plain text mails only, please.
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ALSA: hda/realtek - Fix mem leak (and rid us of trailing whitespace).
@ 2012-04-13 5:38 ` Takashi Iwai
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2012-04-13 5:38 UTC (permalink / raw)
To: Jesper Juhl
Cc: alsa-devel, Kailang Yang, linux-kernel, PeiSen Hou,
Jonathan Woithe, David Henningsson
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 <jj@chaosbits.net>
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 <jj@chaosbits.net> http://www.chaosbits.net/
> Don't top-post http://www.catb.org/jargon/html/T/top-post.html
> Plain text mails only, please.
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-04-13 5:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-12 20:11 [PATCH] ALSA: hda/realtek - Fix mem leak (and rid us of trailing whitespace) Jesper Juhl
2012-04-12 20:11 ` Jesper Juhl
2012-04-13 5:38 ` Takashi Iwai
2012-04-13 5:38 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.