linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] integer overflow issue in 'appletouch' driver
@ 2010-03-05 19:47 Vadim Zaliva
  2010-03-08  7:41 ` Johannes Berg
  2010-03-10 17:37 ` Vadim Zaliva
  0 siblings, 2 replies; 13+ messages in thread
From: Vadim Zaliva @ 2010-03-05 19:47 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-kernel

This small patch is fixing an integer overflow issue in 'appletouch' driver.

In particular, 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.


diff -uNr linux-source-2.6.31.orig/drivers/input/mouse/appletouch.c linux-source-2.6.31/drivers/input/mouse/appletouch.c
--- linux-source-2.6.31.orig/drivers/input/mouse/appletouch.c	2009-09-09 15:13:59.000000000 -0700
+++ linux-source-2.6.31/drivers/input/mouse/appletouch.c	2010-03-05 11:05:11.921394055 -0800
@@ -205,8 +205,8 @@
 	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 @@
 
 	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 */



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-06-20  0:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-05 19:47 [PATCH 1/1] integer overflow issue in 'appletouch' driver Vadim Zaliva
2010-03-08  7:41 ` Johannes Berg
2010-03-09 19:43   ` Vadim Zaliva
2010-03-10  6:22     ` Dmitry Torokhov
2010-08-07 14:00       ` Serge Belyshev
2010-08-07 15:47         ` Johannes Berg
2010-08-09  0:20           ` Benjamin Herrenschmidt
2010-08-09  1:24             ` Vadim Zaliva
2010-08-09  3:43               ` Benjamin Herrenschmidt
2010-08-09 16:33                 ` Dmitry Torokhov
2010-08-09 22:36                   ` Benjamin Herrenschmidt
2018-06-20  0:24                 ` Dmitry Torokhov
2010-03-10 17:37 ` Vadim Zaliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).