提交 df311333 编写于 作者: A Axel Lin 提交者: Anton Vorontsov

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: NAxel Lin <axel.lin@ingics.com>
Acked-by: NLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: NAnton Vorontsov <anton@enomsg.org>
上级 17b4565b
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册