lkml.org 
[lkml]   [2010]   [Aug]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 4/4] regulator/wm8994-regulator: fix potential NULL dereference
FromAxel Lin <>
DateFri, 20 Aug 2010 10:02:41 +0800
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




\
 
 \ /
  Last update: 2010-08-20 04:03    [from the cache]
©2003-2010