2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-24 13:13:57 +08:00

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>
This commit is contained in:
Axel Lin 2013-05-16 17:31:00 +08:00 committed by Anton Vorontsov
parent 17b4565b30
commit df311333a8

View File

@ -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;
}