Re: [PATCH] pwm: ipq: prevent potential 32-bit integer overflow in hi_div calculation

From: Uwe Kleine-König

Date: Mon Sep 07 2026 - 05:57:52 EST


Hello,

On Fri, Jul 24, 2026 at 10:18:54AM +0530, kr494167@xxxxxxxxx wrote:
> From: Surendra Singh Chouhan <kr494167@xxxxxxxxx>
>
> In ipq_pwm_get_state(), hi_div was calculated as:
> hi_div = hi_dur * (pre_div + 1);
>
> hi_dur and (pre_div + 1) are both unsigned int (32-bit) values.
> Evaluating their multiplication using 32-bit arithmetic before assigning to
> the 64-bit u64 hi_div variable can overflow 32-bit unsigned math.
>
> While effective_div explicitly uses (u64)(pwm_div + 1) * (pre_div + 1) to
> prevent overflow, hi_div was missing the (u64) cast.
>
> Fix this by casting hi_dur to (u64) before multiplication, matching the
> precision used for effective_div.
>
> Fixes: c436e3e9c265 ("pwm: Driver for qualcomm ipq6018 pwm block")
> Signed-off-by: Surendra Singh Chouhan <kr494167@xxxxxxxxx>

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next

. Did you find this issue by code review or does it trigger easily? If
the latter you might be able to convince me to send this patch to Linus
before 7.3.

Best regards
Uwe

Attachment: signature.asc
Description: PGP signature