summaryrefslogtreecommitdiffstats
path: root/drivers/power/pm2301_charger.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2013-05-16 17:31:00 +0800
committerAnton Vorontsov <anton@enomsg.org>2013-06-06 17:25:27 -0700
commitdf311333a8c13f3ffe2537a4ff507887208cb863 (patch)
tree3d52e87564f8537623d465f52c6d632ee949746b /drivers/power/pm2301_charger.c
parent17b4565b308ed31fa20b59842c75e685a101dc8a (diff)
pm2301_charger: Fix NULL pointer dereference
Add checking pl_data in probe, this prevent possible NULL pointer dereference. Also fix NULL pointer deference in dev_err when allocate memory for pm2 fails. Signed-off-by: Axel Lin <axel.lin@ingics.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Anton Vorontsov <anton@enomsg.org>
Diffstat (limited to 'drivers/power/pm2301_charger.c')
-rw-r--r--drivers/power/pm2301_charger.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/power/pm2301_charger.c b/drivers/power/pm2301_charger.c
index fef56e2041b..bb346becd7b 100644
--- a/drivers/power/pm2301_charger.c
+++ b/drivers/power/pm2301_charger.c
@@ -1007,9 +1007,14 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
u8 val;
int i;
+ if (!pl_data) {
+ dev_err(&i2c_client->dev, "No platform data supplied\n");
+ return -EINVAL;
+ }
+
pm2 = kzalloc(sizeof(struct pm2xxx_charger), GFP_KERNEL);
if (!pm2) {
- dev_err(pm2->dev, "pm2xxx_charger allocation failed\n");
+ dev_err(&i2c_client->dev, "pm2xxx_charger allocation failed\n");
return -ENOMEM;
}