public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [2.6 patch] sound/: fix some memory leaks
@ 2006-03-13 22:26 Adrian Bunk
  2006-03-14  9:39 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Adrian Bunk @ 2006-03-13 22:26 UTC (permalink / raw)
  To: perex; +Cc: alsa-devel, linux-kernel

This patch fixes two memory leaks spotted by the Coverity checker.


Signed-off-by: Adrian Bunk <bunk@stusta.de>

---

 sound/drivers/serial-u16550.c |    1 +
 sound/isa/es18xx.c            |    1 +
 sound/pci/cs46xx/dsp_spos.c   |   10 +++++++---
 3 files changed, 9 insertions(+), 3 deletions(-)

--- linux-2.6.16-rc6-mm1-full/sound/drivers/serial-u16550.c.old	2006-03-13 22:52:25.000000000 +0100
+++ linux-2.6.16-rc6-mm1-full/sound/drivers/serial-u16550.c	2006-03-13 22:52:59.000000000 +0100
@@ -789,6 +789,7 @@ static int __init snd_uart16550_create(s
 
 	if ((err = snd_uart16550_detect(uart)) <= 0) {
 		printk(KERN_ERR "no UART detected at 0x%lx\n", iobase);
+		kfree(uart);
 		return -ENODEV;
 	}
 
--- linux-2.6.16-rc6-mm1-full/sound/isa/es18xx.c.old	2006-03-13 22:53:43.000000000 +0100
+++ linux-2.6.16-rc6-mm1-full/sound/isa/es18xx.c	2006-03-13 22:54:03.000000000 +0100
@@ -2083,6 +2083,7 @@ static int __devinit snd_audiodrive_pnp(
 	err = pnp_activate_dev(acard->devc);
 	if (err < 0) {
 		snd_printk(KERN_ERR PFX "PnP control configure failure (out of resources?)\n");
+		kfree(cfg);
 		return -EAGAIN;
 	}
 	snd_printdd("pnp: port=0x%lx\n", pnp_port_start(acard->devc, 0));
--- linux-2.6.16-rc6-mm1-full/sound/pci/cs46xx/dsp_spos.c.old	2006-03-13 22:55:23.000000000 +0100
+++ linux-2.6.16-rc6-mm1-full/sound/pci/cs46xx/dsp_spos.c	2006-03-13 22:56:30.000000000 +0100
@@ -237,7 +237,7 @@ struct dsp_spos_instance *cs46xx_dsp_spo
 
 	if (ins->symbol_table.symbols == NULL) {
 		cs46xx_dsp_spos_destroy(chip);
-		return NULL;
+		goto error;
 	}
 
 	ins->code.offset = 0;
@@ -246,7 +246,7 @@ struct dsp_spos_instance *cs46xx_dsp_spo
 
 	if (ins->code.data == NULL) {
 		cs46xx_dsp_spos_destroy(chip);
-		return NULL;
+		goto error;
 	}
 
 	ins->nscb = 0;
@@ -257,7 +257,7 @@ struct dsp_spos_instance *cs46xx_dsp_spo
 
 	if (ins->modules == NULL) {
 		cs46xx_dsp_spos_destroy(chip);
-		return NULL;
+		goto error;
 	}
 
 	/* default SPDIF input sample rate
@@ -280,6 +280,10 @@ struct dsp_spos_instance *cs46xx_dsp_spo
 	 /* left and right validity bits */ (1 << 13) | (1 << 12);
 
 	return ins;
+
+error:
+	kfree(ins);
+	return NULL;
 }
 
 void  cs46xx_dsp_spos_destroy (struct snd_cs46xx * chip)


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

* Re: [2.6 patch] sound/: fix some memory leaks
  2006-03-13 22:26 [2.6 patch] sound/: fix some memory leaks Adrian Bunk
@ 2006-03-14  9:39 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2006-03-14  9:39 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: perex, alsa-devel, linux-kernel

At Mon, 13 Mar 2006 23:26:47 +0100,
Adrian Bunk wrote:
> 
> This patch fixes two memory leaks spotted by the Coverity checker.
> 
> 
> Signed-off-by: Adrian Bunk <bunk@stusta.de>
> 
> ---
> 
>  sound/drivers/serial-u16550.c |    1 +
>  sound/isa/es18xx.c            |    1 +
>  sound/pci/cs46xx/dsp_spos.c   |   10 +++++++---
>  3 files changed, 9 insertions(+), 3 deletions(-)
> 
> --- linux-2.6.16-rc6-mm1-full/sound/drivers/serial-u16550.c.old	2006-03-13 22:52:25.000000000 +0100
> +++ linux-2.6.16-rc6-mm1-full/sound/drivers/serial-u16550.c	2006-03-13 22:52:59.000000000 +0100
> @@ -789,6 +789,7 @@ static int __init snd_uart16550_create(s
>  
>  	if ((err = snd_uart16550_detect(uart)) <= 0) {
>  		printk(KERN_ERR "no UART detected at 0x%lx\n", iobase);
> +		kfree(uart);
>  		return -ENODEV;
>  	}

This one may leave a requested region after free.  It should be
snd_uart16550_free(uart), instead.

Others look fine.  I'll apply them with the fix above to ALSA tree.


Thanks!

Takashi

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

end of thread, other threads:[~2006-03-14  9:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-13 22:26 [2.6 patch] sound/: fix some memory leaks Adrian Bunk
2006-03-14  9:39 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox