aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2010-08-14 09:44:04 -0400
committerLiam Girdwood <lrg@slimlogic.co.uk>2010-09-01 07:59:33 -0400
commitd4876a3bc041e8e40af20b8addbec6d0a42e3842 (patch)
tree7cb5e7ec063b68dcda315c3a95824f23f08f7359 /drivers
parentb3fcf3e576749b911e984e752b6b390c326efb76 (diff)
regulator: ab8500 - fix the logic to remove already registered regulators in error path
In current implementation, ab8500_regulator_info[0].regulator is not unregistered if the error happen at i > 0. This patch fixes the resource leak and also improves the readability. Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Linus Walleij <linus.walleij@stericsson.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/regulator/ab8500.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index cc7cbafc5b9..3d09580dc88 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -369,11 +369,9 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
369 dev_err(&pdev->dev, "failed to register regulator %s\n", 369 dev_err(&pdev->dev, "failed to register regulator %s\n",
370 info->desc.name); 370 info->desc.name);
371 /* when we fail, un-register all earlier regulators */ 371 /* when we fail, un-register all earlier regulators */
372 i--; 372 while (--i >= 0) {
373 while (i > 0) {
374 info = &ab8500_regulator_info[i]; 373 info = &ab8500_regulator_info[i];
375 regulator_unregister(info->regulator); 374 regulator_unregister(info->regulator);
376 i--;
377 } 375 }
378 return err; 376 return err;
379 } 377 }