aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2013-05-16 05:31:00 -0400
committerAnton Vorontsov <anton@enomsg.org>2013-06-06 20:25:27 -0400
commitdf311333a8c13f3ffe2537a4ff507887208cb863 (patch)
tree3d52e87564f8537623d465f52c6d632ee949746b /drivers/power
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')
-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 fef56e2041b3..bb346becd7b4 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,
1007 u8 val; 1007 u8 val;
1008 int i; 1008 int i;
1009 1009
1010 if (!pl_data) {
1011 dev_err(&i2c_client->dev, "No platform data supplied\n");
1012 return -EINVAL;
1013 }
1014
1010 pm2 = kzalloc(sizeof(struct pm2xxx_charger), GFP_KERNEL); 1015 pm2 = kzalloc(sizeof(struct pm2xxx_charger), GFP_KERNEL);
1011 if (!pm2) { 1016 if (!pm2) {
1012 dev_err(pm2->dev, "pm2xxx_charger allocation failed\n"); 1017 dev_err(&i2c_client->dev, "pm2xxx_charger allocation failed\n");
1013 return -ENOMEM; 1018 return -ENOMEM;
1014 } 1019 }
1015 1020