Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+8
+8
drivers/pwm/pwm-stm32.c
··· 536 536 struct device_node *np) 537 537 { 538 538 int nb, ret, array_size; 539 + unsigned int i; 539 540 540 541 nb = of_property_count_elems_of_size(np, "st,breakinput", 541 542 sizeof(struct stm32_breakinput)); ··· 557 556 (u32 *)priv->breakinputs, array_size); 558 557 if (ret) 559 558 return ret; 559 + 560 + for (i = 0; i < priv->num_breakinputs; i++) { 561 + if (priv->breakinputs[i].index > 1 || 562 + priv->breakinputs[i].level > 1 || 563 + priv->breakinputs[i].filter > 15) 564 + return -EINVAL; 565 + } 560 566 561 567 return stm32_pwm_apply_breakinputs(priv); 562 568 }