Commit baf73e2c authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

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: default avatarAxel Lin <axel.lin@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent f503071b
...@@ -785,11 +785,6 @@ static int lp872x_config(struct lp872x *lp) ...@@ -785,11 +785,6 @@ static int lp872x_config(struct lp872x *lp)
struct lp872x_platform_data *pdata = lp->pdata; struct lp872x_platform_data *pdata = lp->pdata;
int ret; int ret;
if (!pdata) {
dev_warn(lp->dev, "no platform data\n");
return 0;
}
if (!pdata->update_config) if (!pdata->update_config)
return 0; return 0;
...@@ -889,6 +884,11 @@ static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id) ...@@ -889,6 +884,11 @@ static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
[LP8725] = LP8725_NUM_REGULATORS, [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); lp = devm_kzalloc(&cl->dev, sizeof(struct lp872x), GFP_KERNEL);
if (!lp) if (!lp)
goto err_mem; goto err_mem;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment