2010-08-25 08:56:14

by Axel Lin

[permalink] [raw]
Subject: [PATCH] ASoC: pxa-ssp: fix a memory leak in pxa_ssp_remove()

The "priv" allocated in pxa_ssp_probe() should be kfreed in pxa_ssp_remove().

Signed-off-by: Axel Lin <[email protected]>
---
This patch is against 2.6.36-rc2-git3.
sound/soc/pxa/pxa-ssp.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
index a1fd23e..2a9cac7 100644
--- a/sound/soc/pxa/pxa-ssp.c
+++ b/sound/soc/pxa/pxa-ssp.c
@@ -760,6 +760,7 @@ static void pxa_ssp_remove(struct platform_device *pdev,
{
struct ssp_priv *priv = dai->private_data;
pxa_ssp_free(priv->ssp);
+ kfree(priv);
}

#define PXA_SSP_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
--
1.7.2



2010-08-25 09:53:18

by Liam Girdwood

[permalink] [raw]
Subject: Re: [PATCH] ASoC: pxa-ssp: fix a memory leak in pxa_ssp_remove()

On Wed, 2010-08-25 at 16:59 +0800, Axel Lin wrote:
> The "priv" allocated in pxa_ssp_probe() should be kfreed in pxa_ssp_remove().
>
> Signed-off-by: Axel Lin <[email protected]>
> ---
> This patch is against 2.6.36-rc2-git3.
> sound/soc/pxa/pxa-ssp.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c
> index a1fd23e..2a9cac7 100644
> --- a/sound/soc/pxa/pxa-ssp.c
> +++ b/sound/soc/pxa/pxa-ssp.c
> @@ -760,6 +760,7 @@ static void pxa_ssp_remove(struct platform_device *pdev,
> {
> struct ssp_priv *priv = dai->private_data;
> pxa_ssp_free(priv->ssp);
> + kfree(priv);
> }
>
> #define PXA_SSP_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\

Acked-by:Liam Girdwood <[email protected]>
--
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

2010-08-25 13:21:57

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] ASoC: pxa-ssp: fix a memory leak in pxa_ssp_remove()

On Wed, Aug 25, 2010 at 04:59:11PM +0800, Axel Lin wrote:
> The "priv" allocated in pxa_ssp_probe() should be kfreed in pxa_ssp_remove().
>
> Signed-off-by: Axel Lin <[email protected]>

This doesn't apply against current ASoC. I fixed this up by hand since
the error was so trivial but in future could you please make sure you
generate your code against the latest version of ASoC? This will be in
-next at any given time, or for the individual tree you want the latest
for-2.6.nn branch of:

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6.git

2010-08-26 06:10:30

by Axel Lin

[permalink] [raw]
Subject: Re: [PATCH] ASoC: pxa-ssp: fix a memory leak in pxa_ssp_remove()

2010/8/25 Mark Brown <[email protected]>:
> On Wed, Aug 25, 2010 at 04:59:11PM +0800, Axel Lin wrote:
>> The "priv" allocated in pxa_ssp_probe() should be kfreed in pxa_ssp_remove().
>>
>> Signed-off-by: Axel Lin <[email protected]>
>
> This doesn't apply against current ASoC. ?I fixed this up by hand since
> the error was so trivial but in future could you please make sure you
> generate your code against the latest version of ASoC? ?This will be in
> -next at any given time, or for the individual tree you want the latest
> for-2.6.nn branch of:
>
> ?git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6.git
>

Thanks, Mark.
I just thought this fix should be applied to 2.6.36.
And ASoC tree will have this fix after merge 2.6.36.

Regards,
Axel

2010-08-26 08:47:13

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] ASoC: pxa-ssp: fix a memory leak in pxa_ssp_remove()

On Thu, Aug 26, 2010 at 02:10:06PM +0800, Axel Lin wrote:
> I just thought this fix should be applied to 2.6.36.
> And ASoC tree will have this fix after merge 2.6.36.

It's a memory leak on unload for a driver for a device integrated into
an embedded SoC - I'd be astonished if anyone managed to run into it in
production.