Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d4876a3b authored by Axel Lin's avatar Axel Lin Committed by Liam Girdwood
Browse files

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: default avatarAxel Lin <axel.lin@gmail.com>
Acked-by: default avatarLinus Walleij <linus.walleij@stericsson.com>
Acked-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
parent b3fcf3e5
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -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;
		}