Skip to content

Commit

Permalink
regulator: ab3100 - 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, ab3100_regulators[0].rdev 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 af54dec commit b3fcf3e
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions drivers/regulator/ab3100.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,12 +634,9 @@ static int __devinit ab3100_regulators_probe(struct platform_device *pdev)
"%s: failed to register regulator %s err %d\n",
__func__, ab3100_regulator_desc[i].name,
err);
i--;
/* remove the already registered regulators */
while (i > 0) {
while (--i >= 0)
regulator_unregister(ab3100_regulators[i].rdev);
i--;
}
return err;
}

Expand Down

0 comments on commit b3fcf3e

Please sign in to comment.