lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 04 Aug 2013 09:23:28 +0800
From:	Axel Lin <axel.lin@...ics.com>
To:	Mark Brown <broonie@...nel.org>
Cc:	"Joseph(Yossi) Hanin" <yhanin@...vell.com>,
	Yi Zhang <yizhang@...vell.com>,
	Chao Xie <chao.xie@...vell.com>,
	Liam Girdwood <lgirdwood@...il.com>,
	linux-kernel@...r.kernel.org
Subject: [PATCH] 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: Axel Lin <axel.lin@...ics.com>
---
 drivers/regulator/88pm800.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/88pm800.c b/drivers/regulator/88pm800.c
index c72fe95..58e9b74 100644
--- a/drivers/regulator/88pm800.c
+++ b/drivers/regulator/88pm800.c
@@ -299,10 +299,13 @@ static int pm800_regulator_probe(struct platform_device *pdev)
 			return -ENODEV;
 		}
 	} else if (pdata->num_regulators) {
-		/* Check whether num_regulator is valid. */
 		unsigned int count = 0;
-		for (i = 0; pdata->regulators[i]; i++)
-			count++;
+
+		/* Check whether num_regulator is valid. */
+		for (i = 0; ARRAY_SIZE(pdata->regulators); i++) {
+			if (pdata->regulators[i])
+				count++;
+		}
 		if (count != pdata->num_regulators)
 			return -EINVAL;
 	} else {
-- 
1.8.1.2



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ