Skip to content

Commit

Permalink
regulator: ab8500 - fix the logic to remove already registered regula…
Browse files Browse the repository at this point in the history
…tors 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>
  • Loading branch information
Axel Lin authored and Liam Girdwood committed Sep 1, 2010
1 parent b3fcf3e commit d4876a3
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/regulator/ab8500.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,9 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "failed to register regulator %s\n",
info->desc.name);
/* when we fail, un-register all earlier regulators */
i--;
while (i > 0) {
while (--i >= 0) {
info = &ab8500_regulator_info[i];
regulator_unregister(info->regulator);
i--;
}
return err;
}
Expand Down

0 comments on commit d4876a3

Please sign in to comment.