drivers: led_pwm: fix overflow in set_brightness
The set_brightness function of the led_pwm driver uses a default PWM period (defined in the pwms DT property) to compute a pulse passed to the pwm_set_pulse_dt function. If this default period is greater than 2^32/100 nanoseconds (about 43 milliseconds) then the calculation may overflow. This patch prevents this overflow by running the pulse computation under a cast with a larger type (uint64_t). Reported-by:Scott Worley <scott.worley@microchip.com> Signed-off-by:
Simon Guinot <simon.guinot@seagate.com>
Loading
Please sign in to comment