diff options
author | Dan Carpenter <error27@gmail.com> | 2010-03-07 07:36:45 -0500 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-03-22 15:44:44 -0400 |
commit | 67e46f347eb25222e2b415540b6ba3fd2574afe2 (patch) | |
tree | 9592b35a6228ed1c491805b38733b6f8dc709b78 /drivers/regulator/lp3971.c | |
parent | 3fff6c04d81a2852821135736fad2d8386464753 (diff) |
regulator: handle kcalloc() failure
Return -ENOMEM if kcalloc() fails
Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator/lp3971.c')
-rw-r--r-- | drivers/regulator/lp3971.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c index f5532ed79272..55fab4a30645 100644 --- a/drivers/regulator/lp3971.c +++ b/drivers/regulator/lp3971.c | |||
@@ -439,6 +439,10 @@ static int __devinit setup_regulators(struct lp3971 *lp3971, | |||
439 | lp3971->num_regulators = pdata->num_regulators; | 439 | lp3971->num_regulators = pdata->num_regulators; |
440 | lp3971->rdev = kcalloc(pdata->num_regulators, | 440 | lp3971->rdev = kcalloc(pdata->num_regulators, |
441 | sizeof(struct regulator_dev *), GFP_KERNEL); | 441 | sizeof(struct regulator_dev *), GFP_KERNEL); |
442 | if (!lp3971->rdev) { | ||
443 | err = -ENOMEM; | ||
444 | goto err_nomem; | ||
445 | } | ||
442 | 446 | ||
443 | /* Instantiate the regulators */ | 447 | /* Instantiate the regulators */ |
444 | for (i = 0; i < pdata->num_regulators; i++) { | 448 | for (i = 0; i < pdata->num_regulators; i++) { |
@@ -461,6 +465,7 @@ error: | |||
461 | regulator_unregister(lp3971->rdev[i]); | 465 | regulator_unregister(lp3971->rdev[i]); |
462 | kfree(lp3971->rdev); | 466 | kfree(lp3971->rdev); |
463 | lp3971->rdev = NULL; | 467 | lp3971->rdev = NULL; |
468 | err_nomem: | ||
464 | return err; | 469 | return err; |
465 | } | 470 | } |
466 | 471 | ||