mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 11:19:37 +00:00
Input: appletouch - fix integer overflow issue
When reading data from Geyser 2 touchpads used on post Oct 2005 Apple PowerBooks the driver was casting X and Y coordinates values to 'signed char'. Testing on one of such PowerBooks I have noticed that touchpad always generates positive values, but some of them are greater that 127, and thus, when cast to 'signed char' being interpreted as a negative. Such bigger values have been observed infrequently, closer to the edges of a touchpad, so the problem was not very visible. Nevertheless, the patch would potentially improve touchpad driver accuracy. Signed-off-by: Vadim Zaliva <lord@crocodile.org> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
parent
4eb6f91b95
commit
04b4b88cca
1 changed files with 3 additions and 3 deletions
|
@ -205,8 +205,8 @@ struct atp {
|
|||
bool overflow_warned;
|
||||
int x_old; /* last reported x/y, */
|
||||
int y_old; /* used for smoothing */
|
||||
signed char xy_cur[ATP_XSENSORS + ATP_YSENSORS];
|
||||
signed char xy_old[ATP_XSENSORS + ATP_YSENSORS];
|
||||
u8 xy_cur[ATP_XSENSORS + ATP_YSENSORS];
|
||||
u8 xy_old[ATP_XSENSORS + ATP_YSENSORS];
|
||||
int xy_acc[ATP_XSENSORS + ATP_YSENSORS];
|
||||
int idlecount; /* number of empty packets */
|
||||
struct work_struct work;
|
||||
|
@ -531,7 +531,7 @@ static void atp_complete_geyser_1_2(struct urb *urb)
|
|||
|
||||
for (i = 0; i < ATP_XSENSORS + ATP_YSENSORS; i++) {
|
||||
/* accumulate the change */
|
||||
signed char change = dev->xy_old[i] - dev->xy_cur[i];
|
||||
int change = dev->xy_old[i] - dev->xy_cur[i];
|
||||
dev->xy_acc[i] -= change;
|
||||
|
||||
/* prevent down drifting */
|
||||
|
|
Loading…
Reference in a new issue