2007-08-04 00:11:24

by Jesper Juhl

[permalink] [raw]
Subject: [PATCH] au88x0: mem leak fix in snd_vortex_create()

Hi,

In sound/pci/au88x0/au88x0.c::snd_vortex_create() :
The Coverity checker found that if we allocate storage for 'chip'
but then leave via the regions_out: label, then we end up leaking
the storage allocated for 'chip'.
I believe simply freeing 'chip' before the "return err;" line is
all we need to fix this, but please double-check me :)


Signed-off-by: Jesper Juhl <[email protected]>
---

diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c
index 5ec1b6f..f70286a 100644
--- a/sound/pci/au88x0/au88x0.c
+++ b/sound/pci/au88x0/au88x0.c
@@ -232,6 +232,7 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip)
pci_disable_device(chip->pci_dev);
//FIXME: this not the right place to unregister the gameport
vortex_gameport_unregister(chip);
+ kfree(chip);
return err;
}




2007-08-04 09:50:25

by Rene Herman

[permalink] [raw]
Subject: Re: [PATCH] au88x0: mem leak fix in snd_vortex_create()

On 08/04/2007 02:09 AM, Jesper Juhl wrote:

> In sound/pci/au88x0/au88x0.c::snd_vortex_create() :
> The Coverity checker found that if we allocate storage for 'chip'
> but then leave via the regions_out: label, then we end up leaking
> the storage allocated for 'chip'.
> I believe simply freeing 'chip' before the "return err;" line is
> all we need to fix this, but please double-check me :)
>
>
> Signed-off-by: Jesper Juhl <[email protected]>
> ---
>
> diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c
> index 5ec1b6f..f70286a 100644
> --- a/sound/pci/au88x0/au88x0.c
> +++ b/sound/pci/au88x0/au88x0.c
> @@ -232,6 +232,7 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip)
> pci_disable_device(chip->pci_dev);
> //FIXME: this not the right place to unregister the gameport
> vortex_gameport_unregister(chip);
> + kfree(chip);
> return err;
> }

ACK.

Rene.

2007-08-06 12:07:03

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH] au88x0: mem leak fix in snd_vortex_create()

At Sat, 4 Aug 2007 02:09:25 +0200,
Jesper Juhl wrote:
>
> Hi,
>
> In sound/pci/au88x0/au88x0.c::snd_vortex_create() :
> The Coverity checker found that if we allocate storage for 'chip'
> but then leave via the regions_out: label, then we end up leaking
> the storage allocated for 'chip'.
> I believe simply freeing 'chip' before the "return err;" line is
> all we need to fix this, but please double-check me :)
>
>
> Signed-off-by: Jesper Juhl <[email protected]>

Thanks, applied to ALSA tree now.


Takashi