Re: [PATCH v2] HID: pidff: Fix integer overflow in pidff_rescale

From: Jiri Kosina

Date: Tue May 12 2026 - 12:25:20 EST


On Sun, 10 May 2026, Tomasz Pakuła wrote:

> Rescaling values close to the max (U16_MAX) temporarily creates values
> that exceed the s32 range. This caused value overflow in case when, for
> example, a periodic effect phase was higer than 180 degrees. In turn,
> rescale function could return values outised of the logical range of the
> HID field.
>
> Fix by using 64 bit signed integer to store the value during calculation
> but still return only 32 bit integer.
>
> Closes: https://github.com/JacKeTUs/universal-pidff/issues/116
> Fixes: 224ee88fe395 ("Input: add force feedback driver for PID devices")
> Cc: <stable@xxxxxxxxxxxxxxx>
> Signed-off-by: Tomasz Pakuła <tomasz.pakula.oficjalny@xxxxxxxxx>

Applied, thanks.

--
Jiri Kosina
SUSE Labs