Skip to content

Commit

Permalink
regulator: lp872x: Return -EINVAL if pdata is NULL
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Axel Lin authored and Mark Brown committed Jun 20, 2012
1 parent f503071 commit baf73e2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/regulator/lp872x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit baf73e2

Please sign in to comment.