NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: PR/45872 CVS commit: src/sys/dev/usb
Hi there,
working again on PR/45872, I would like to commit the patch below.
> 2. Division by zero
> -------------------
I have confirmed this issue to be correct, although not happening on a
regular kernel because GCC optimizes away at -O2. I believe this patch
would fix it for real.
Additionally, tpcalib_reset() does not fully (re-)initialize the relevant
data, as uninitialized or outdated data can be returned through the
WSMOUSEIO_GCALIBCOORDS ioctl; this patch should fix this too.
Let me know if I can commit this:
Index: sys/dev/wscons/tpcalib.c
===================================================================
RCS file: /cvsroot/src/sys/dev/wscons/tpcalib.c,v
retrieving revision 1.11
diff -p -u -r1.11 tpcalib.c
--- sys/dev/wscons/tpcalib.c 4 Mar 2007 06:02:51 -0000 1.11
+++ sys/dev/wscons/tpcalib.c 11 Oct 2012 23:54:24 -0000
@@ -65,7 +65,9 @@ tpcalib_init(struct tpcalib_softc *sc)
void
tpcalib_reset(struct tpcalib_softc *sc)
{
- /* This indicate 'raw mode'. No translation will be done. */
+ memset(&sc->sc_saved, 0, sizeof(sc->sc_saved));
+
+ /* This indicates 'raw mode'. No translation will be done. */
sc->sc_saved.samplelen = WSMOUSE_CALIBCOORDS_RESET;
}
Index: sys/dev/wscons/mra.c
===================================================================
RCS file: /cvsroot/src/sys/dev/wscons/mra.c,v
retrieving revision 1.4
diff -p -u -r1.4 mra.c
--- sys/dev/wscons/mra.c 9 Oct 2006 10:43:01 -0000 1.4
+++ sys/dev/wscons/mra.c 11 Oct 2012 23:54:24 -0000
@@ -59,8 +59,13 @@ mra_Y_AX1_BX2_C(const int *y, int ys,
#define X2(i) AA(x2, x2s, i)
#define Y(i) AA(y, ys, i)
+ /* avoid any division by zero later */
+ if (n == 0) {
+ return -1;
+ }
+
/*
- * get avarage and sum
+ * get average and sum
*/
X1a = 0; X2a = 0; Ya = 0;
X1X1s = 0; X2X2s = 0; X1X2s = 0;
Cheers,
--
khorben
Home |
Main Index |
Thread Index |
Old Index