regulator: lp872x: Return -EINVAL if pdata is NULL
authorAxel Lin <axel.lin@gmail.com>
Wed, 20 Jun 2012 08:13:15 +0000 (16:13 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 20 Jun 2012 10:18:38 +0000 (11:18 +0100)
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>
drivers/regulator/lp872x.c

index d51d09852041988c3e47bd92db879fd4b5d03084..e8f54efb19850609601ef44d0b0d7793c9a8f8ff 100644 (file)
@@ -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;
This page took 0.027018 seconds and 5 git commands to generate.