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

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

regulator: max8998 - fix memory allocation size for max8998->rdev



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: default avatarAxel Lin <axel.lin@gmail.com>
Acked-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
parent 7112b2df
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -549,7 +549,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
	if (!max8998)
	if (!max8998)
		return -ENOMEM;
		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);
	max8998->rdev = kzalloc(size, GFP_KERNEL);
	if (!max8998->rdev) {
	if (!max8998->rdev) {
		kfree(max8998);
		kfree(max8998);
@@ -583,7 +583,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)


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


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


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