* [PATCH] Fix a memory leak in pdaudiocf
@ 2006-05-13 21:44 Jesper Juhl
2006-05-15 8:39 ` [Alsa-devel] " Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Jesper Juhl @ 2006-05-13 21:44 UTC (permalink / raw)
To: Jaroslav Kysela; +Cc: linux-kernel, alsa-devel, 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().
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.
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [Alsa-devel] [PATCH] Fix a memory leak in pdaudiocf
2006-05-13 21:44 [PATCH] Fix a memory leak in pdaudiocf Jesper Juhl
@ 2006-05-15 8:39 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2006-05-15 8:39 UTC (permalink / raw)
To: Jesper Juhl; +Cc: Jaroslav Kysela, linux-kernel, alsa-devel
At Sat, 13 May 2006 23:44:25 +0200,
Jesper Juhl wrote:
>
> 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.
This bug was already fixed in a different way on ALSA HG repo.
thanks,
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-05-15 8:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-13 21:44 [PATCH] Fix a memory leak in pdaudiocf Jesper Juhl
2006-05-15 8:39 ` [Alsa-devel] " Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox