Skip to content

Commit

Permalink
Input: ff-memless - fix signed to unsigned bit overflow
Browse files Browse the repository at this point in the history
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: Jussi Kivilinna <[email protected]>
Acked-by: Anssi Hannula <[email protected]>
Signed-off-by: Dmitry Torokhov <[email protected]>
  • Loading branch information
jkivilin authored and dtor committed May 8, 2009
1 parent d07a9cb commit 9e68177
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/input/ff-memless.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static int get_compatible_type(struct ff_device *ff, int effect_type)
*/
static void ml_combine_effects(struct ff_effect *effect,
struct ml_effect_state *state,
int gain)
unsigned int gain)
{
struct ff_effect *new = state->effect;
unsigned int strong, weak, i;
Expand Down

0 comments on commit 9e68177

Please sign in to comment.