[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100307123645.GB6469@bicker>
Date: Sun, 7 Mar 2010 15:36:45 +0300
From: Dan Carpenter <error27@...il.com>
To: Liam Girdwood <lrg@...mlogic.co.uk>
Cc: Mark Brown <broonie@...nsource.wolfsonmicro.com>,
Julia Lawall <julia@...u.dk>, Dmitry Torokhov <dtor@...l.ru>,
Wolfram Sang <w.sang@...gutronix.de>,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: [patch] regulator: handle kcalloc() failure
Return -ENOMEM if kcalloc() fails
Signed-off-by: Dan Carpenter <error27@...il.com>
diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c
index f5532ed..55fab4a 100644
--- a/drivers/regulator/lp3971.c
+++ b/drivers/regulator/lp3971.c
@@ -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;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists