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
| ||
|
Date: Thu, 2 Jun 2016 11:23:14 +0100 From: Srinivas Kandagatla <srinivas.kandagatla@...aro.org> To: bjorn.andersson@...aro.org, Mark Brown <broonie@...nel.org> Cc: linux-kernel@...r.kernel.org, Liam Girdwood <lgirdwood@...il.com>, linux-arm-msm@...r.kernel.org, Srinivas Kandagatla <srinivas.kandagatla@...aro.org> Subject: [RFC PATCH v1 1/3] regulator: helpers: consider constriants in list_voltage_linear_range Regulator drivers can have linear range which is according to the regualtor hardware spec, however the board level device tree files can restrict this range by adding constriants. These constriants are not considered in the exsiting code, which gives false supported voltage range to the consumers. Fix this by adding constriants check in the helper function. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@...aro.org> --- For now I have added this support for regulator_list_voltage_linear_range() If it makes sense we can extend this to other list voltage helpers too. drivers/regulator/helpers.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c index bcf38fd..379b2b3 100644 --- a/drivers/regulator/helpers.c +++ b/drivers/regulator/helpers.c @@ -16,6 +16,7 @@ #include <linux/delay.h> #include <linux/regmap.h> #include <linux/regulator/consumer.h> +#include <linux/regulator/machine.h> #include <linux/regulator/driver.h> #include <linux/module.h> @@ -374,7 +375,7 @@ int regulator_list_voltage_linear_range(struct regulator_dev *rdev, unsigned int selector) { const struct regulator_linear_range *range; - int i; + int i, v; if (!rdev->desc->n_linear_ranges) { BUG_ON(!rdev->desc->n_linear_ranges); @@ -389,8 +390,13 @@ int regulator_list_voltage_linear_range(struct regulator_dev *rdev, continue; selector -= range->min_sel; + v = range->min_uV + (range->uV_step * selector); - return range->min_uV + (range->uV_step * selector); + if (v < rdev->constraints->min_uV || + v > rdev->constraints->max_uV) + return -EINVAL; + else + return v; } return -EINVAL; -- 2.8.2
Powered by blists - more mailing lists