2010-08-24 05:41:01

by Axel Lin

[permalink] [raw]
Subject: [PATCH 1/3] mfd: da903x - fix da903x_add_subdevs error path

This patch fixes da903x_add_subdevs error path:
1. return -ENOMEM if platform_device_alloc() fail.
2. call platform_device_put() if platform_device_add() fail.

Signed-off-by: Axel Lin <[email protected]>
---
drivers/mfd/da903x.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/da903x.c b/drivers/mfd/da903x.c
index c07aece..2fadbae 100644
--- a/drivers/mfd/da903x.c
+++ b/drivers/mfd/da903x.c
@@ -470,13 +470,19 @@ static int __devinit da903x_add_subdevs(struct da903x_chip *chip,
subdev = &pdata->subdevs[i];

pdev = platform_device_alloc(subdev->name, subdev->id);
+ if (!pdev) {
+ ret = -ENOMEM;
+ goto failed;
+ }

pdev->dev.parent = chip->dev;
pdev->dev.platform_data = subdev->platform_data;

ret = platform_device_add(pdev);
- if (ret)
+ if (ret) {
+ platform_device_put(pdev);
goto failed;
+ }
}
return 0;

--
1.7.2



2010-08-24 05:42:42

by Axel Lin

[permalink] [raw]
Subject: [PATCH 2/3] mfd: ezx-pcap - fix pcap_add_subdev error path

1. return -ENOMEM if platform_device_alloc() fail.
2. call platform_device_put() if platform_device_add() fail.

Signed-off-by: Axel Lin <[email protected]>
---
drivers/mfd/ezx-pcap.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/ezx-pcap.c b/drivers/mfd/ezx-pcap.c
index 134c69a..d283d77 100644
--- a/drivers/mfd/ezx-pcap.c
+++ b/drivers/mfd/ezx-pcap.c
@@ -384,12 +384,20 @@ static int __devinit pcap_add_subdev(struct pcap_chip *pcap,
struct pcap_subdev *subdev)
{
struct platform_device *pdev;
+ int ret;

pdev = platform_device_alloc(subdev->name, subdev->id);
+ if (!pdev)
+ return -ENOMEM;
+
pdev->dev.parent = &pcap->spi->dev;
pdev->dev.platform_data = subdev->platform_data;

- return platform_device_add(pdev);
+ ret = platform_device_add(pdev);
+ if (ret)
+ platform_device_put(pdev);
+
+ return ret;
}

static int __devexit ezx_pcap_remove(struct spi_device *spi)
--
1.7.2


2010-08-24 05:44:16

by Axel Lin

[permalink] [raw]
Subject: [PATCH 3/3] mfd: tps6586x - fix tps6586x_add_subdevs error path

1. return -ENOMEM if platform_device_alloc() fail.
2. call platform_device_put() if platform_device_add() fail.

Signed-off-by: Axel Lin <[email protected]>
---
drivers/mfd/tps6586x.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
index 4cde31e..1c91936 100644
--- a/drivers/mfd/tps6586x.c
+++ b/drivers/mfd/tps6586x.c
@@ -273,13 +273,19 @@ static int __devinit tps6586x_add_subdevs(struct tps6586x *tps6586x,
subdev = &pdata->subdevs[i];

pdev = platform_device_alloc(subdev->name, subdev->id);
+ if (!pdev) {
+ ret = -ENOMEM;
+ goto failed;
+ }

pdev->dev.parent = tps6586x->dev;
pdev->dev.platform_data = subdev->platform_data;

ret = platform_device_add(pdev);
- if (ret)
+ if (ret) {
+ platform_device_put(pdev);
goto failed;
+ }
}
return 0;

--
1.7.2


2010-08-24 05:48:08

by Eric Miao

[permalink] [raw]
Subject: Re: [PATCH 1/3] mfd: da903x - fix da903x_add_subdevs error path

On Tue, Aug 24, 2010 at 1:44 PM, Axel Lin <[email protected]> wrote:
> This patch fixes da903x_add_subdevs error path:
> 1. return -ENOMEM if platform_device_alloc() fail.
> 2. call platform_device_put() if platform_device_add() fail.
>
> Signed-off-by: Axel Lin <[email protected]>

Acked-by: Eric Miao <[email protected]>

> ---
>  drivers/mfd/da903x.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mfd/da903x.c b/drivers/mfd/da903x.c
> index c07aece..2fadbae 100644
> --- a/drivers/mfd/da903x.c
> +++ b/drivers/mfd/da903x.c
> @@ -470,13 +470,19 @@ static int __devinit da903x_add_subdevs(struct da903x_chip *chip,
>                subdev = &pdata->subdevs[i];
>
>                pdev = platform_device_alloc(subdev->name, subdev->id);
> +               if (!pdev) {
> +                       ret = -ENOMEM;
> +                       goto failed;
> +               }
>
>                pdev->dev.parent = chip->dev;
>                pdev->dev.platform_data = subdev->platform_data;
>
>                ret = platform_device_add(pdev);
> -               if (ret)
> +               if (ret) {
> +                       platform_device_put(pdev);
>                        goto failed;
> +               }
>        }
>        return 0;
>
> --
> 1.7.2
>
>
>
>
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2010-08-24 06:14:23

by Mike Rapoport

[permalink] [raw]
Subject: Re: [PATCH 3/3] mfd: tps6586x - fix tps6586x_add_subdevs error path

Axel Lin wrote:
> 1. return -ENOMEM if platform_device_alloc() fail.
> 2. call platform_device_put() if platform_device_add() fail.
>
> Signed-off-by: Axel Lin <[email protected]>

Acked-by: Mike Rapoport <[email protected]>

> ---
> drivers/mfd/tps6586x.c | 8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c
> index 4cde31e..1c91936 100644
> --- a/drivers/mfd/tps6586x.c
> +++ b/drivers/mfd/tps6586x.c
> @@ -273,13 +273,19 @@ static int __devinit tps6586x_add_subdevs(struct tps6586x *tps6586x,
> subdev = &pdata->subdevs[i];
>
> pdev = platform_device_alloc(subdev->name, subdev->id);
> + if (!pdev) {
> + ret = -ENOMEM;
> + goto failed;
> + }
>
> pdev->dev.parent = tps6586x->dev;
> pdev->dev.platform_data = subdev->platform_data;
>
> ret = platform_device_add(pdev);
> - if (ret)
> + if (ret) {
> + platform_device_put(pdev);
> goto failed;
> + }
> }
> return 0;
>


--
Sincerely yours,
Mike.

2010-08-24 06:14:32

by Mike Rapoport

[permalink] [raw]
Subject: Re: [PATCH 1/3] mfd: da903x - fix da903x_add_subdevs error path

Axel Lin wrote:
> This patch fixes da903x_add_subdevs error path:
> 1. return -ENOMEM if platform_device_alloc() fail.
> 2. call platform_device_put() if platform_device_add() fail.
>
> Signed-off-by: Axel Lin <[email protected]>

Acked-by: Mike Rapoport <[email protected]>

> ---
> drivers/mfd/da903x.c | 8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mfd/da903x.c b/drivers/mfd/da903x.c
> index c07aece..2fadbae 100644
> --- a/drivers/mfd/da903x.c
> +++ b/drivers/mfd/da903x.c
> @@ -470,13 +470,19 @@ static int __devinit da903x_add_subdevs(struct da903x_chip *chip,
> subdev = &pdata->subdevs[i];
>
> pdev = platform_device_alloc(subdev->name, subdev->id);
> + if (!pdev) {
> + ret = -ENOMEM;
> + goto failed;
> + }
>
> pdev->dev.parent = chip->dev;
> pdev->dev.platform_data = subdev->platform_data;
>
> ret = platform_device_add(pdev);
> - if (ret)
> + if (ret) {
> + platform_device_put(pdev);
> goto failed;
> + }
> }
> return 0;
>


--
Sincerely yours,
Mike.