linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda - Fix a memory leak bug
@ 2019-08-10  4:29 Wenwen Wang
  2019-08-10  7:57 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Wenwen Wang @ 2019-08-10  4:29 UTC (permalink / raw)
  To: Wenwen Wang
  Cc: Jaroslav Kysela, Takashi Iwai, Pierre-Louis Bossart, Mark Brown,
	Kate Stewart, Jacek Anaszewski, Greg Kroah-Hartman,
	Thomas Gleixner, moderated list:SOUND, open list

In snd_hda_parse_generic_codec(), 'spec' is allocated through kzalloc().
Then, the pin widgets in 'codec' are parsed. However, if the parsing
process fails, 'spec' is not deallocated, leading to a memory leak.

To fix the above issue, free 'spec' before returning the error.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
---
 sound/pci/hda/hda_generic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 485edab..8f2beb1 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -6100,7 +6100,7 @@ static int snd_hda_parse_generic_codec(struct hda_codec *codec)
 
 	err = snd_hda_parse_pin_defcfg(codec, &spec->autocfg, NULL, 0);
 	if (err < 0)
-		return err;
+		goto error;
 
 	err = snd_hda_gen_parse_auto_config(codec, &spec->autocfg);
 	if (err < 0)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ALSA: hda - Fix a memory leak bug
  2019-08-10  4:29 [PATCH] ALSA: hda - Fix a memory leak bug Wenwen Wang
@ 2019-08-10  7:57 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2019-08-10  7:57 UTC (permalink / raw)
  To: Wenwen Wang
  Cc: moderated list:SOUND, Jacek Anaszewski, Mark Brown,
	Thomas Gleixner, Pierre-Louis Bossart, Greg Kroah-Hartman,
	Kate Stewart, Jaroslav Kysela, Takashi Iwai, open list

On Sat, 10 Aug 2019 06:29:48 +0200,
Wenwen Wang wrote:
> 
> In snd_hda_parse_generic_codec(), 'spec' is allocated through kzalloc().
> Then, the pin widgets in 'codec' are parsed. However, if the parsing
> process fails, 'spec' is not deallocated, leading to a memory leak.
> 
> To fix the above issue, free 'spec' before returning the error.
> 
> Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>

Applied, thanks.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-10  7:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-10  4:29 [PATCH] ALSA: hda - Fix a memory leak bug Wenwen Wang
2019-08-10  7:57 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).