Skip to content

Commit

Permalink
regulator: max8998 - fix memory allocation size for max8998->rdev
Browse files Browse the repository at this point in the history
We only use max8998->rdev[0] .. max8998->rdev[pdata->num_regulators-1],
max8998->rdev[pdata->num_regulators] is not used.
Thus fix the memory allocation size.

Signed-off-by: Axel Lin <axel.lin@gmail.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 7112b2d commit 11fa0d1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/regulator/max8998.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
if (!max8998)
return -ENOMEM;

size = sizeof(struct regulator_dev *) * (pdata->num_regulators + 1);
size = sizeof(struct regulator_dev *) * pdata->num_regulators;
max8998->rdev = kzalloc(size, GFP_KERNEL);
if (!max8998->rdev) {
kfree(max8998);
Expand Down Expand Up @@ -583,7 +583,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)

return 0;
err:
for (i = 0; i <= max8998->num_regulators; i++)
for (i = 0; i < max8998->num_regulators; i++)
if (rdev[i])
regulator_unregister(rdev[i]);

Expand All @@ -599,7 +599,7 @@ static int __devexit max8998_pmic_remove(struct platform_device *pdev)
struct regulator_dev **rdev = max8998->rdev;
int i;

for (i = 0; i <= max8998->num_regulators; i++)
for (i = 0; i < max8998->num_regulators; i++)
if (rdev[i])
regulator_unregister(rdev[i]);

Expand Down

0 comments on commit 11fa0d1

Please sign in to comment.