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

Commit 19c6b544 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown
Browse files

regulator: 88pm800: Fix checking whether num_regulator is valid



The code to check whether num_regulator is valid is wrong because it should
iterate all array entries rather than break from the for loop if
pdata->regulators[i] is NULL.

Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 6625d9d2
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -299,10 +299,13 @@ static int pm800_regulator_probe(struct platform_device *pdev)
			return -ENODEV;
			return -ENODEV;
		}
		}
	} else if (pdata->num_regulators) {
	} else if (pdata->num_regulators) {
		/* Check whether num_regulator is valid. */
		unsigned int count = 0;
		unsigned int count = 0;
		for (i = 0; pdata->regulators[i]; i++)

		/* Check whether num_regulator is valid. */
		for (i = 0; ARRAY_SIZE(pdata->regulators); i++) {
			if (pdata->regulators[i])
				count++;
				count++;
		}
		if (count != pdata->num_regulators)
		if (count != pdata->num_regulators)
			return -EINVAL;
			return -EINVAL;
	} else {
	} else {