提交 67e46f34 编写于 作者: D Dan Carpenter 提交者: Liam Girdwood

regulator: handle kcalloc() failure

Return -ENOMEM if kcalloc() fails
Signed-off-by: NDan Carpenter <error27@gmail.com>
Acked-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: NWolfram Sang <w.sang@pengutronix.de>
Signed-off-by: NLiam Girdwood <lrg@slimlogic.co.uk>
上级 3fff6c04
......@@ -439,6 +439,10 @@ static int __devinit setup_regulators(struct lp3971 *lp3971,
lp3971->num_regulators = pdata->num_regulators;
lp3971->rdev = kcalloc(pdata->num_regulators,
sizeof(struct regulator_dev *), GFP_KERNEL);
if (!lp3971->rdev) {
err = -ENOMEM;
goto err_nomem;
}
/* Instantiate the regulators */
for (i = 0; i < pdata->num_regulators; i++) {
......@@ -461,6 +465,7 @@ static int __devinit setup_regulators(struct lp3971 *lp3971,
regulator_unregister(lp3971->rdev[i]);
kfree(lp3971->rdev);
lp3971->rdev = NULL;
err_nomem:
return err;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册