* [PATCH 1/4] regulator/wm831x-dcdc: fix potential NULL dereference
@ 2010-08-20 1:58 Axel Lin
2010-08-20 1:59 ` [PATCH 2/4] regulator/wm831x-isink: " Axel Lin
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Axel Lin @ 2010-08-20 1:58 UTC (permalink / raw)
To: linux-kernel; +Cc: Mark Brown, Liam Girdwood
pdata is dereferenced earlier than tested for being NULL.
Thus move the dereference of "pdata" below the check for NULL.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/wm831x-dcdc.c | 36 ++++++++++++++++++++++++------------
1 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
index dbfaf59..ed66fac 100644
--- a/drivers/regulator/wm831x-dcdc.c
+++ b/drivers/regulator/wm831x-dcdc.c
@@ -501,14 +501,17 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev)
{
struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
struct wm831x_pdata *pdata = wm831x->dev->platform_data;
- int id = pdev->id % ARRAY_SIZE(pdata->dcdc);
struct wm831x_dcdc *dcdc;
struct resource *res;
- int ret, irq;
+ int id, ret, irq;
+ if (pdata == NULL)
+ return -ENODEV;
+
+ id = pdev->id % ARRAY_SIZE(pdata->dcdc);
dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1);
- if (pdata == NULL || pdata->dcdc[id] == NULL)
+ if (pdata->dcdc[id] == NULL)
return -ENODEV;
dcdc = kzalloc(sizeof(struct wm831x_dcdc), GFP_KERNEL);
@@ -704,14 +707,17 @@ static __devinit int wm831x_buckp_probe(struct platform_device *pdev)
{
struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
struct wm831x_pdata *pdata = wm831x->dev->platform_data;
- int id = pdev->id % ARRAY_SIZE(pdata->dcdc);
struct wm831x_dcdc *dcdc;
struct resource *res;
- int ret, irq;
+ int id, ret, irq;
+ if (pdata == NULL)
+ return -ENODEV;
+
+ id = pdev->id % ARRAY_SIZE(pdata->dcdc);
dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1);
- if (pdata == NULL || pdata->dcdc[id] == NULL)
+ if (pdata->dcdc[id] == NULL)
return -ENODEV;
dcdc = kzalloc(sizeof(struct wm831x_dcdc), GFP_KERNEL);
@@ -834,14 +840,17 @@ static __devinit int wm831x_boostp_probe(struct platform_device *pdev)
{
struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
struct wm831x_pdata *pdata = wm831x->dev->platform_data;
- int id = pdev->id % ARRAY_SIZE(pdata->dcdc);
struct wm831x_dcdc *dcdc;
struct resource *res;
- int ret, irq;
+ int id, ret, irq;
+ if (pdata == NULL)
+ return -ENODEV;
+
+ id = pdev->id % ARRAY_SIZE(pdata->dcdc);
dev_dbg(&pdev->dev, "Probing DCDC%d\n", id + 1);
- if (pdata == NULL || pdata->dcdc[id] == NULL)
+ if (pdata->dcdc[id] == NULL)
return -ENODEV;
dcdc = kzalloc(sizeof(struct wm831x_dcdc), GFP_KERNEL);
@@ -940,13 +949,16 @@ static __devinit int wm831x_epe_probe(struct platform_device *pdev)
{
struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
struct wm831x_pdata *pdata = wm831x->dev->platform_data;
- int id = pdev->id % ARRAY_SIZE(pdata->epe);
struct wm831x_dcdc *dcdc;
- int ret;
+ int id, ret;
+
+ if (pdata == NULL)
+ return -ENODEV;
+ id = pdev->id % ARRAY_SIZE(pdata->epe);
dev_dbg(&pdev->dev, "Probing EPE%d\n", id + 1);
- if (pdata == NULL || pdata->epe[id] == NULL)
+ if (pdata->epe[id] == NULL)
return -ENODEV;
dcdc = kzalloc(sizeof(struct wm831x_dcdc), GFP_KERNEL);
--
1.7.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] regulator/wm831x-isink: fix potential NULL dereference
2010-08-20 1:58 [PATCH 1/4] regulator/wm831x-dcdc: fix potential NULL dereference Axel Lin
@ 2010-08-20 1:59 ` Axel Lin
2010-08-20 2:01 ` [PATCH 3/4] regulator/wm831x-ldo: " Axel Lin
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Axel Lin @ 2010-08-20 1:59 UTC (permalink / raw)
To: linux-kernel; +Cc: Mark Brown, Liam Girdwood
pdata is dereferenced earlier than tested for being NULL.
Thus move the dereference of "pdata" below the check for NULL.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/wm831x-isink.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c
index 6c446cd..123d722 100644
--- a/drivers/regulator/wm831x-isink.c
+++ b/drivers/regulator/wm831x-isink.c
@@ -153,13 +153,16 @@ static __devinit int wm831x_isink_probe(struct platform_device *pdev)
struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
struct wm831x_pdata *pdata = wm831x->dev->platform_data;
struct wm831x_isink *isink;
- int id = pdev->id % ARRAY_SIZE(pdata->isink);
struct resource *res;
- int ret, irq;
+ int id, ret, irq;
+ if (pdata == NULL)
+ return -ENODEV;
+
+ id = pdev->id % ARRAY_SIZE(pdata->isink);
dev_dbg(&pdev->dev, "Probing ISINK%d\n", id + 1);
- if (pdata == NULL || pdata->isink[id] == NULL)
+ if (pdata->isink[id] == NULL)
return -ENODEV;
isink = kzalloc(sizeof(struct wm831x_isink), GFP_KERNEL);
--
1.7.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] regulator/wm831x-ldo: fix potential NULL dereference
2010-08-20 1:58 [PATCH 1/4] regulator/wm831x-dcdc: fix potential NULL dereference Axel Lin
2010-08-20 1:59 ` [PATCH 2/4] regulator/wm831x-isink: " Axel Lin
@ 2010-08-20 2:01 ` Axel Lin
2010-08-20 2:02 ` [PATCH 4/4] regulator/wm8994-regulator: " Axel Lin
2010-08-20 9:03 ` [PATCH 1/4] regulator/wm831x-dcdc: " Mark Brown
3 siblings, 0 replies; 6+ messages in thread
From: Axel Lin @ 2010-08-20 2:01 UTC (permalink / raw)
To: linux-kernel; +Cc: Mark Brown, Liam Girdwood
pdata is dereferenced earlier than tested for being NULL.
Thus move the dereference of "pdata" below the check for NULL.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/wm831x-ldo.c | 27 ++++++++++++++++++---------
1 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c
index e686cdb..040515d 100644
--- a/drivers/regulator/wm831x-ldo.c
+++ b/drivers/regulator/wm831x-ldo.c
@@ -303,14 +303,17 @@ static __devinit int wm831x_gp_ldo_probe(struct platform_device *pdev)
{
struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
struct wm831x_pdata *pdata = wm831x->dev->platform_data;
- int id = pdev->id % ARRAY_SIZE(pdata->ldo);
struct wm831x_ldo *ldo;
struct resource *res;
- int ret, irq;
+ int id, ret, irq;
+ if (pdata == NULL)
+ return -ENODEV;
+
+ id = pdev->id % ARRAY_SIZE(pdata->ldo);
dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1);
- if (pdata == NULL || pdata->ldo[id] == NULL)
+ if (pdata->ldo[id] == NULL)
return -ENODEV;
ldo = kzalloc(sizeof(struct wm831x_ldo), GFP_KERNEL);
@@ -563,14 +566,17 @@ static __devinit int wm831x_aldo_probe(struct platform_device *pdev)
{
struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
struct wm831x_pdata *pdata = wm831x->dev->platform_data;
- int id = pdev->id % ARRAY_SIZE(pdata->ldo);
struct wm831x_ldo *ldo;
struct resource *res;
- int ret, irq;
+ int id, ret, irq;
+
+ if (pdata == NULL)
+ return -ENODEV;
+ id = pdev->id % ARRAY_SIZE(pdata->ldo);
dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1);
- if (pdata == NULL || pdata->ldo[id] == NULL)
+ if (pdata->ldo[id] == NULL)
return -ENODEV;
ldo = kzalloc(sizeof(struct wm831x_ldo), GFP_KERNEL);
@@ -749,14 +755,17 @@ static __devinit int wm831x_alive_ldo_probe(struct platform_device *pdev)
{
struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
struct wm831x_pdata *pdata = wm831x->dev->platform_data;
- int id = pdev->id % ARRAY_SIZE(pdata->ldo);
struct wm831x_ldo *ldo;
struct resource *res;
- int ret;
+ int id, ret;
+
+ if (pdata == NULL)
+ return -ENODEV;
+ id = pdev->id % ARRAY_SIZE(pdata->ldo);
dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1);
- if (pdata == NULL || pdata->ldo[id] == NULL)
+ if (pdata->ldo[id] == NULL)
return -ENODEV;
ldo = kzalloc(sizeof(struct wm831x_ldo), GFP_KERNEL);
--
1.7.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] regulator/wm8994-regulator: fix potential NULL dereference
2010-08-20 1:58 [PATCH 1/4] regulator/wm831x-dcdc: fix potential NULL dereference Axel Lin
2010-08-20 1:59 ` [PATCH 2/4] regulator/wm831x-isink: " Axel Lin
2010-08-20 2:01 ` [PATCH 3/4] regulator/wm831x-ldo: " Axel Lin
@ 2010-08-20 2:02 ` Axel Lin
2010-08-20 9:03 ` [PATCH 1/4] regulator/wm831x-dcdc: " Mark Brown
3 siblings, 0 replies; 6+ messages in thread
From: Axel Lin @ 2010-08-20 2:02 UTC (permalink / raw)
To: linux-kernel; +Cc: Mark Brown, Liam Girdwood
pdata is dereferenced earlier than tested for being NULL.
Thus move the dereference of "pdata" below the check for NULL.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/wm8994-regulator.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c
index 03713bc..3ecc81f 100644
--- a/drivers/regulator/wm8994-regulator.c
+++ b/drivers/regulator/wm8994-regulator.c
@@ -202,15 +202,15 @@ static __devinit int wm8994_ldo_probe(struct platform_device *pdev)
{
struct wm8994 *wm8994 = dev_get_drvdata(pdev->dev.parent);
struct wm8994_pdata *pdata = wm8994->dev->platform_data;
- int id = pdev->id % ARRAY_SIZE(pdata->ldo);
struct wm8994_ldo *ldo;
- int ret;
-
- dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1);
+ int id, ret;
if (!pdata)
return -ENODEV;
+ id = pdev->id % ARRAY_SIZE(pdata->ldo);
+ dev_dbg(&pdev->dev, "Probing LDO%d\n", id + 1);
+
ldo = kzalloc(sizeof(struct wm8994_ldo), GFP_KERNEL);
if (ldo == NULL) {
dev_err(&pdev->dev, "Unable to allocate private data\n");
--
1.7.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/4] regulator/wm831x-dcdc: fix potential NULL dereference
2010-08-20 1:58 [PATCH 1/4] regulator/wm831x-dcdc: fix potential NULL dereference Axel Lin
` (2 preceding siblings ...)
2010-08-20 2:02 ` [PATCH 4/4] regulator/wm8994-regulator: " Axel Lin
@ 2010-08-20 9:03 ` Mark Brown
2010-08-20 15:43 ` Axel Lin
3 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2010-08-20 9:03 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Liam Girdwood
On 20 Aug 2010, at 02:58, Axel Lin <axel.lin@gmail.com> wrote:
> pdata is dereferenced earlier than tested for being NULL.
> Thus move the dereference of "pdata" below the check for NULL.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
> drivers/regulator/wm831x-dcdc.c | 36 ++++++++++++++++++++++++------------
> 1 files changed, 24 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
> index dbfaf59..ed66fac 100644
> --- a/drivers/regulator/wm831x-dcdc.c
> +++ b/drivers/regulator/wm831x-dcdc.c
> @@ -501,14 +501,17 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev)
> {
> struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
> struct wm831x_pdata *pdata = wm831x->dev->platform_data;
> - int id = pdev->id % ARRAY_SIZE(pdata->dcdc);
ARRAY_SIZE() isn't actually a dereference, it's evaluated at compile time.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/4] regulator/wm831x-dcdc: fix potential NULL dereference
2010-08-20 9:03 ` [PATCH 1/4] regulator/wm831x-dcdc: " Mark Brown
@ 2010-08-20 15:43 ` Axel Lin
0 siblings, 0 replies; 6+ messages in thread
From: Axel Lin @ 2010-08-20 15:43 UTC (permalink / raw)
To: Mark Brown; +Cc: linux-kernel, Liam Girdwood
2010/8/20 Mark Brown <broonie@opensource.wolfsonmicro.com>:
> On 20 Aug 2010, at 02:58, Axel Lin <axel.lin@gmail.com> wrote:
>
>> pdata is dereferenced earlier than tested for being NULL.
>> Thus move the dereference of "pdata" below the check for NULL.
>>
>> Signed-off-by: Axel Lin <axel.lin@gmail.com>
>> ---
>> drivers/regulator/wm831x-dcdc.c | 36 ++++++++++++++++++++++++------------
>> 1 files changed, 24 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c
>> index dbfaf59..ed66fac 100644
>> --- a/drivers/regulator/wm831x-dcdc.c
>> +++ b/drivers/regulator/wm831x-dcdc.c
>> @@ -501,14 +501,17 @@ static __devinit int wm831x_buckv_probe(struct platform_device *pdev)
>> {
>> struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
>> struct wm831x_pdata *pdata = wm831x->dev->platform_data;
>> - int id = pdev->id % ARRAY_SIZE(pdata->dcdc);
>
> ARRAY_SIZE() isn't actually a dereference, it's evaluated at compile time.
Ah. You are right! Thanks.
Axel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-08-20 15:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-20 1:58 [PATCH 1/4] regulator/wm831x-dcdc: fix potential NULL dereference Axel Lin
2010-08-20 1:59 ` [PATCH 2/4] regulator/wm831x-isink: " Axel Lin
2010-08-20 2:01 ` [PATCH 3/4] regulator/wm831x-ldo: " Axel Lin
2010-08-20 2:02 ` [PATCH 4/4] regulator/wm8994-regulator: " Axel Lin
2010-08-20 9:03 ` [PATCH 1/4] regulator/wm831x-dcdc: " Mark Brown
2010-08-20 15:43 ` Axel Lin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.