Skip to content
Commit 9e68177e authored by Jussi Kivilinna's avatar Jussi Kivilinna Committed by Dmitry Torokhov
Browse files

Input: ff-memless - fix signed to unsigned bit overflow



When userspace sets effect->u.rumble.strong_magnitude to 0x8001 or
larger, ml_combine_effects() would always return strong_magnitude
0xffff.

Problem is that 'gain' is passed in as signed integer. Multiplying
magnitude (__u16) with gain (int) causes magnitude read as signed and
results negative value (with magnitude > 0x8000). This signed integer
is then divided and value, still negative, converted to 32bit unsigned
integer. Finally checking combine overflow min(new+old, 0xffff) gives
out 0xffff.

Fix is to simply change 'gain' to unsigned int.

Signed-off-by: default avatarJussi Kivilinna <jussi.kivilinna@mbnet.fi>
Acked-by: default avatarAnssi Hannula <anssi.hannula@gmail.com>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent d07a9cba
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment