Skip to content
Commit a4645908 authored by Simon Guinot's avatar Simon Guinot Committed by Fabio Baltieri
Browse files

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: default avatarScott Worley <scott.worley@microchip.com>
Signed-off-by: default avatarSimon Guinot <simon.guinot@seagate.com>
parent 64ec7e18
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment