diff options
| author | Matthias Schiffer <[email protected]> | 2023-06-30 14:30:07 +0200 |
|---|---|---|
| committer | Anatolij Gustschin <[email protected]> | 2023-07-14 18:12:37 +0200 |
| commit | 533ad9dcda38a78c7965e9cea8a05c80d18449e4 (patch) | |
| tree | bd8f811e57b12d47c2a5a30e62cd3a1c3902bc2e /drivers | |
| parent | 6a0b8885802a4548de9ee54494033b4f19a01b56 (diff) | |
video: backlight: pwm: avoid integer overflow in duty cycle calculation
The intermediate value could overflow for large periods and levels.
Signed-off-by: Matthias Schiffer <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/video/pwm_backlight.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/video/pwm_backlight.c b/drivers/video/pwm_backlight.c index d7c096923b3..46c16a8f447 100644 --- a/drivers/video/pwm_backlight.c +++ b/drivers/video/pwm_backlight.c @@ -63,7 +63,7 @@ static int set_pwm(struct pwm_backlight_priv *priv) int ret; if (priv->period_ns) { - duty_cycle = priv->period_ns * (priv->cur_level - priv->min_level) / + duty_cycle = (u64)priv->period_ns * (priv->cur_level - priv->min_level) / (priv->max_level - priv->min_level); ret = pwm_set_config(priv->pwm, priv->channel, priv->period_ns, duty_cycle); |
