[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1282269761.31048.8.camel@mola>
Date: Fri, 20 Aug 2010 10:02:41 +0800
From: Axel Lin <axel.lin@...il.com>
To: linux-kernel <linux-kernel@...r.kernel.org>
Cc: Mark Brown <broonie@...nsource.wolfsonmicro.com>,
Liam Girdwood <lrg@...mlogic.co.uk>
Subject: [PATCH 4/4] regulator/wm8994-regulator: fix potential NULL
dereference
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@...il.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists