public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jesper Juhl <jesper.juhl@gmail.com>
To: Jaroslav Kysela <perex@suse.cz>
Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org,
	Jesper Juhl <jesper.juhl@gmail.com>
Subject: [PATCH] Fix a memory leak in pdaudiocf
Date: Sat, 13 May 2006 23:44:25 +0200	[thread overview]
Message-ID: <200605132344.25862.jesper.juhl@gmail.com> (raw)

There's a potential memory leak in 
sound/pcmcia/pdaudiocf/pdaudiocf.c::pdacf_config()

If we leave via one of the *failed: labels we may leak 'parse', so add a 
kfree(parse) to the end of the function and also make sure to set 'parse' 
to NULL after the kfree() call a little further up so we don't do a 
double-free of the pointer if we hit one of the *failed: labels after the 
first kfree().

Since I don't have the hardware I can't test the patch beyond making sure 
it compiles cleanly, but I feel pretty confident that it is correct.

Please consider for inclusion.


Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---

 sound/pcmcia/pdaudiocf/pdaudiocf.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletion(-)

--- linux-2.6.17-rc4-git2-orig/sound/pcmcia/pdaudiocf/pdaudiocf.c	2006-05-13 21:28:55.000000000 +0200
+++ linux-2.6.17-rc4-git2/sound/pcmcia/pdaudiocf/pdaudiocf.c	2006-05-13 23:27:46.000000000 +0200
@@ -226,7 +226,7 @@ static int pdacf_config(struct pcmcia_de
 
 	snd_printdd(KERN_DEBUG "pdacf_config called\n");
 	parse = kmalloc(sizeof(*parse), GFP_KERNEL);
-	if (! parse) {
+	if (!parse) {
 		snd_printk(KERN_ERR "pdacf_config: cannot allocate\n");
 		return -ENOMEM;
 	}
@@ -242,6 +242,7 @@ static int pdacf_config(struct pcmcia_de
 	link->conf.ConfigBase = parse->config.base;
 	link->conf.ConfigIndex = 0x5;
 	kfree(parse);
+	parse = NULL;
 
 	CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io));
 	CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
@@ -257,6 +258,7 @@ cs_failed:
 	cs_error(link, last_fn, last_ret);
 failed:
 	pcmcia_disable_device(link);
+	kfree(parse);
 	return -ENODEV;
 }
 





PS. Please keep me on Cc when replying since I'm not subscribed to alsa-devel.


             reply	other threads:[~2006-05-13 21:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-13 21:44 Jesper Juhl [this message]
2006-05-15  8:39 ` [Alsa-devel] [PATCH] Fix a memory leak in pdaudiocf Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200605132344.25862.jesper.juhl@gmail.com \
    --to=jesper.juhl@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox