diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-06-20 04:13:15 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-20 06:18:38 -0400 |
commit | baf73e2c4e25aa57a7bd5df90a93e65be0542c74 (patch) | |
tree | b09c903aa74c239f30a550f8de6abb433ad991bd /drivers/regulator/lp872x.c | |
parent | f503071b03dcac6908fb7e051cfc9c45bea084c0 (diff) |
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.c | 10 |
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) | |||
785 | struct lp872x_platform_data *pdata = lp->pdata; | 785 | struct lp872x_platform_data *pdata = lp->pdata; |
786 | int ret; | 786 | int ret; |
787 | 787 | ||
788 | if (!pdata) { | ||
789 | dev_warn(lp->dev, "no platform data\n"); | ||
790 | return 0; | ||
791 | } | ||
792 | |||
793 | if (!pdata->update_config) | 788 | if (!pdata->update_config) |
794 | return 0; | 789 | return 0; |
795 | 790 | ||
@@ -889,6 +884,11 @@ static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id) | |||
889 | [LP8725] = LP8725_NUM_REGULATORS, | 884 | [LP8725] = LP8725_NUM_REGULATORS, |
890 | }; | 885 | }; |
891 | 886 | ||
887 | if (!pdata) { | ||
888 | dev_warn(&cl->dev, "no platform data\n"); | ||
889 | return -EINVAL; | ||
890 | } | ||
891 | |||
892 | lp = devm_kzalloc(&cl->dev, sizeof(struct lp872x), GFP_KERNEL); | 892 | lp = devm_kzalloc(&cl->dev, sizeof(struct lp872x), GFP_KERNEL); |
893 | if (!lp) | 893 | if (!lp) |
894 | goto err_mem; | 894 | goto err_mem; |