summaryrefslogtreecommitdiffstats
path: root/drivers/regulator/lp872x.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-06-20 10:13:15 +0200
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-06-20 12:18:38 +0200
commitbaf73e2c4e25aa57a7bd5df90a93e65be0542c74 (patch)
treeb09c903aa74c239f30a550f8de6abb433ad991bd /drivers/regulator/lp872x.c
parentregulator: max77686: Implement .set_ramp_delay() callback (diff)
downloadlinux-baf73e2c4e25aa57a7bd5df90a93e65be0542c74.tar.xz
linux-baf73e2c4e25aa57a7bd5df90a93e65be0542c74.zip
regulator: lp872x: Return -EINVAL if pdata is NULL
Return -EINVAL if pdata is NULL, otherwise we have NULL dereference bug. This patch also moves the code checking pdata earlier in lp872x_probe. Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/lp872x.c')
-rw-r--r--drivers/regulator/lp872x.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c
index d51d09852041..e8f54efb1985 100644
--- a/drivers/regulator/lp872x.c
+++ b/drivers/regulator/lp872x.c
@@ -785,11 +785,6 @@ static int lp872x_config(struct lp872x *lp)
struct lp872x_platform_data *pdata = lp->pdata;
int ret;
- if (!pdata) {
- dev_warn(lp->dev, "no platform data\n");
- return 0;
- }
-
if (!pdata->update_config)
return 0;
@@ -889,6 +884,11 @@ static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
[LP8725] = LP8725_NUM_REGULATORS,
};
+ if (!pdata) {
+ dev_warn(&cl->dev, "no platform data\n");
+ return -EINVAL;
+ }
+
lp = devm_kzalloc(&cl->dev, sizeof(struct lp872x), GFP_KERNEL);
if (!lp)
goto err_mem;