regulator: handle kcalloc() failure
Subsystems (2)
PATCH 1/1 regulator: handle kcalloc() failure
Return -ENOMEM if kcalloc() fails
Signed-off-by Dan Carpenter <[email protected]>
drivers/regulator/lp3971.c +5 -0
@@ -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 @@ error:regulator_unregister (lp3971->rdev[i]);kfree (lp3971->rdev); lp3971->rdev =NULL ; +err_nomem:return err; }
Quoted 3 lines · Dan Carpenter
Return
-ENOMEMifkcalloc()failsSigned-off-by Dan Carpenter <[email protected]>
Acked-by Mark Brown <[email protected]>
Quoted 3 lines · Dan Carpenter
Return
-ENOMEMifkcalloc()failsSigned-off-by Dan Carpenter <[email protected]>
Acked-by Wolfram Sang <[email protected]>
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
Liam Girdwood
AppliedQuoted 4 lines · Dan Carpenter
Return
-ENOMEMifkcalloc()failsSigned-off-by Dan Carpenter <[email protected]>
Applied.
Thanks
Liam
Signature · 3 lines
Freelance Developer, SlimLogic Ltd ASoC and Voltage Regulator Maintainer. http://www.slimlogic.co.uk