Skip to contentSkip to conversation

Fix a memory leak in pdaudiocf

PATCH In review Jesper Juhl 2 participants 3 messages May 13, 2006 – May 15, 2006 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix a memory leak in pdaudiocf

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.

---

 sound/pcmcia/pdaudiocf/pdaudiocf.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletion(-)
sound/pcmcia/pdaudiocf/pdaudiocf.c +3 -1
@@ -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.

#1 lore raw

At Sat, 13 May 2006 23:44:25 +0200,

Quoted 10 lines · Jesper Juhl

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().

Quoted 4 lines

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.

This bug was already fixed in a different way on ALSA HG repo.

thanks,

Takashi

#2 lore raw
In reply to Jesper Juhl

At Sat, 13 May 2006 23:44:25 +0200,

Quoted 10 lines · Jesper Juhl

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().

Quoted 4 lines

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.

This bug was already fixed in a different way on ALSA HG repo.

thanks,

Takashi

-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642