diff options
author | Uwe Kleine-König <u.kleine-koenig@baylibre.com> | 2025-04-12 14:21:24 +0200 |
---|---|---|
committer | Uwe Kleine-König <ukleinek@kernel.org> | 2025-04-16 07:20:23 +0200 |
commit | dcb882bd436e2124e37640671cfa773dfaed485c (patch) | |
tree | e8c3388573a89f9551b3d33ebfd9f05d02ee3d34 /scripts/generate_rust_analyzer.py | |
parent | 29f1d5cac294dbc0e9ebb9d1fea4e2c1c1d2e5f4 (diff) |
pwm: loongson: Fix u32 overflow in waveform calculation
mul_u64_u64_div_u64() returns an u64 that might be bigger than U32_MAX.
To properly handle this case it must not be directly assigned to an u32
value.
Use a wider type for duty and period to make the idiom:
duty = mul_u64_u64_div_u64(...)
if (duty > U32_MAX)
duty = U32_MAX;
actually work as intended.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/44f3c764-8b65-49a9-b3ad-797e9fbb96f5@stanley.mountain
Fixes: 2b62c89448dd ("pwm: Add Loongson PWM controller support")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Reviewed-by: Binbin Zhou <zhoubinbin@loongson.cn>
Link: https://lore.kernel.org/r/20250412122124.1636152-2-u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
Diffstat (limited to 'scripts/generate_rust_analyzer.py')
0 files changed, 0 insertions, 0 deletions