summaryrefslogtreecommitdiff
path: root/drivers/pwm
diff options
context:
space:
mode:
authorThierry Reding <thierry.reding@gmail.com>2019-10-16 12:06:31 +0200
committerThierry Reding <thierry.reding@gmail.com>2019-10-21 16:50:04 +0200
commit8dfa620e3d70d3eceff59943b29257949505dd33 (patch)
tree2eb94c0dbfbf141de0e73299cd8252e16739bfed /drivers/pwm
parent27938fd8ba78b4c7f9a2385b7b52cca19ab891b8 (diff)
pwm: stm32: Validate breakinput data from DT
Both index and level can only be either 0 or 1 and the filter value is limited to values between (and including) 0 and 15. Validate that the device tree node contains values that are within these ranges. Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r--drivers/pwm/pwm-stm32.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
index 9430b4cd383f..c5f51a33ee1b 100644
--- a/drivers/pwm/pwm-stm32.c
+++ b/drivers/pwm/pwm-stm32.c
@@ -536,6 +536,7 @@ static int stm32_pwm_probe_breakinputs(struct stm32_pwm *priv,
struct device_node *np)
{
int nb, ret, array_size;
+ unsigned int i;
nb = of_property_count_elems_of_size(np, "st,breakinput",
sizeof(struct stm32_breakinput));
@@ -557,6 +558,13 @@ static int stm32_pwm_probe_breakinputs(struct stm32_pwm *priv,
if (ret)
return ret;
+ for (i = 0; i < priv->num_breakinputs; i++) {
+ if (priv->breakinputs[i].index > 1 ||
+ priv->breakinputs[i].level > 1 ||
+ priv->breakinputs[i].filter > 15)
+ return -EINVAL;
+ }
+
return stm32_pwm_apply_breakinputs(priv);
}