2010-11-16 08:02:19

by Axel Lin

[permalink] [raw]
Subject: [PATCH 0/5] ASoC: Fix incorrect kfree in error path

This serial of patches fixes incorrect kfree in error path.

Axel Lin (5):
ASoC: Fix incorrect kfree in ad1836_probe error path
ASoC: Fix incorrect kfree in ad193x_probe error path
ASoC: Fix incorrect kfree in aic3x_probe error path
ASoC: Fix incorrect kfree in wm8731_probe error path
ASoC: Fix incorrect kfree in wm8962_probe error path

sound/soc/codecs/ad1836.c | 1 -
sound/soc/codecs/ad193x.c | 1 -
sound/soc/codecs/tlv320aic3x.c | 1 -
sound/soc/codecs/wm8731.c | 1 -
sound/soc/codecs/wm8962.c | 1 -
5 files changed, 0 insertions(+), 5 deletions(-)

--
1.7.2



2010-11-16 08:03:35

by Axel Lin

[permalink] [raw]
Subject: [PATCH 1/5] ASoC: Fix incorrect kfree in ad1836_probe error path

We allocated memory for ad1836 in ad1836_spi_probe,
and will free the memory in either ad1836_spi_probe error path or
ad1836_spi_remove.

Thus we should not call kfree(ad1836) in ad1836_probe, otherwise
we have double free of ad1836.

Signed-off-by: Axel Lin <[email protected]>
---
sound/soc/codecs/ad1836.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/sound/soc/codecs/ad1836.c b/sound/soc/codecs/ad1836.c
index c71b05d..e5d3db9 100644
--- a/sound/soc/codecs/ad1836.c
+++ b/sound/soc/codecs/ad1836.c
@@ -228,7 +228,6 @@ static int ad1836_probe(struct snd_soc_codec *codec)
if (ret < 0) {
dev_err(codec->dev, "failed to set cache I/O: %d\n",
ret);
- kfree(ad1836);
return ret;
}

--
1.7.2


2010-11-16 08:04:26

by Axel Lin

[permalink] [raw]
Subject: [PATCH 2/5] ASoC: Fix incorrect kfree in ad193x_probe error path

We allocated memory for ad193x in ad193x_spi_probe,
and will free the memory in either ad193x_spi_probe error path or
ad193x_spi_remove.

Thus we should not call kfree(ad193x) in ad193x_probe, otherwise
we have double free of ad193x.

Signed-off-by: Axel Lin <[email protected]>
---
sound/soc/codecs/ad193x.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c
index dc105d8..fd3e659 100644
--- a/sound/soc/codecs/ad193x.c
+++ b/sound/soc/codecs/ad193x.c
@@ -364,7 +364,6 @@ static int ad193x_probe(struct snd_soc_codec *codec)
if (ret < 0) {
dev_err(codec->dev, "failed to set cache I/O: %d\n",
ret);
- kfree(ad193x);
return ret;
}

--
1.7.2


2010-11-16 08:05:16

by Axel Lin

[permalink] [raw]
Subject: [PATCH 3/5] ASoC: Fix incorrect kfree in aic3x_probe error path

We allocated memory for aic3x in aic3x_i2c_probe,
and will free the memory in either aic3x_i2c_probe error path or
aic3x_i2c_remove.

Thus we should not call kfree(aic3x) in aic3x_probe, otherwise
we have double free of aic3x.

Signed-off-by: Axel Lin <[email protected]>
---
sound/soc/codecs/tlv320aic3x.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 6173c2b..df726a5 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -1419,7 +1419,6 @@ err_get:
if (aic3x->gpio_reset >= 0)
gpio_free(aic3x->gpio_reset);
err_gpio:
- kfree(aic3x);
return ret;
}

--
1.7.2


2010-11-16 08:06:15

by Axel Lin

[permalink] [raw]
Subject: [PATCH 4/5] ASoC: Fix incorrect kfree in wm8731_probe error path

We allocated memory for wm8731 in wm8731_spi_probe / wm8731_i2c_probe,
and will free the memory in either wm8731_spi_probe / wm8731_i2c_probe
error path or wm8731_spi_remove / wm8731_i2c_remove.

Thus we should not call kfree(wm8731) in wm8731_probe, otherwise
we have double free of wm8731.

Signed-off-by: Axel Lin <[email protected]>
---
sound/soc/codecs/wm8731.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index 95ade32..4b70958 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -543,7 +543,6 @@ err_regulator_enable:
err_regulator_get:
regulator_bulk_free(ARRAY_SIZE(wm8731->supplies), wm8731->supplies);

- kfree(wm8731);
return ret;
}

--
1.7.2


2010-11-16 08:07:12

by Axel Lin

[permalink] [raw]
Subject: [PATCH 5/5] ASoC: Fix incorrect kfree in wm8962_probe error path

We allocated memory for wm8962 in wm8962_i2c_probe,
and will free the memory in either wm8962_i2c_probe error path
or wm8962_i2c_remove.

Thus we should not call kfree(wm8962) in wm8962_probe, otherwise
we have double free of wm8962.

Signed-off-by: Axel Lin <[email protected]>
---
sound/soc/codecs/wm8962.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index e021866..9f6beca 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -3874,7 +3874,6 @@ err_enable:
err_get:
regulator_bulk_free(ARRAY_SIZE(wm8962->supplies), wm8962->supplies);
err:
- kfree(wm8962);
return ret;
}

--
1.7.2


2010-11-16 09:52:52

by Liam Girdwood

[permalink] [raw]
Subject: Re: [PATCH 0/5] ASoC: Fix incorrect kfree in error path

On Tue, 2010-11-16 at 16:06 +0800, Axel Lin wrote:
> This serial of patches fixes incorrect kfree in error path.
>
> Axel Lin (5):
> ASoC: Fix incorrect kfree in ad1836_probe error path
> ASoC: Fix incorrect kfree in ad193x_probe error path
> ASoC: Fix incorrect kfree in aic3x_probe error path
> ASoC: Fix incorrect kfree in wm8731_probe error path
> ASoC: Fix incorrect kfree in wm8962_probe error path
>
> sound/soc/codecs/ad1836.c | 1 -
> sound/soc/codecs/ad193x.c | 1 -
> sound/soc/codecs/tlv320aic3x.c | 1 -
> sound/soc/codecs/wm8731.c | 1 -
> sound/soc/codecs/wm8962.c | 1 -
> 5 files changed, 0 insertions(+), 5 deletions(-)
>
All

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

2010-11-16 11:37:13

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 0/5] ASoC: Fix incorrect kfree in error path

On Tue, Nov 16, 2010 at 09:52:45AM +0000, Liam Girdwood wrote:
> On Tue, 2010-11-16 at 16:06 +0800, Axel Lin wrote:
> > This serial of patches fixes incorrect kfree in error path.

> All

Applied, thanks.