Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Fix hid_get_data() and hid_get_udata() for 32-bi...
details: https://anonhg.NetBSD.org/src/rev/a75748362009
branches: trunk
changeset: 342831:a75748362009
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Sun Jan 10 17:44:48 2016 +0000
description:
Fix hid_get_data() and hid_get_udata() for 32-bit report data on LP32.
(At least i386 anyway, not sure why ARMv7 doesn't show the same problem.)
diffstat:
sys/dev/usb/hid.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diffs (37 lines):
diff -r 26142ed10a4b -r a75748362009 sys/dev/usb/hid.c
--- a/sys/dev/usb/hid.c Sun Jan 10 16:22:57 2016 +0000
+++ b/sys/dev/usb/hid.c Sun Jan 10 17:44:48 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hid.c,v 1.41 2016/01/09 03:33:53 jakllsch Exp $ */
+/* $NetBSD: hid.c,v 1.42 2016/01/10 17:44:48 jakllsch Exp $ */
/* $FreeBSD: src/sys/dev/usb/hid.c,v 1.11 1999/11/17 22:33:39 n_hibma Exp $ */
/*
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hid.c,v 1.41 2016/01/09 03:33:53 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hid.c,v 1.42 2016/01/10 17:44:48 jakllsch Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -440,7 +440,7 @@
return (0);
data = hid_get_udata(buf, loc);
- if (data < (1UL << (hsize - 1)))
+ if (data < (1UL << (hsize - 1)) || hsize == sizeof(data) * NBBY)
return (data);
return data - (1UL << hsize);
}
@@ -464,7 +464,8 @@
data |= buf[off + i] << (i * 8);
data >>= hpos % 8;
- data &= (1UL << hsize) - 1;
+ if (hsize < sizeof(data) * NBBY)
+ data &= (1UL << hsize) - 1;
DPRINTFN(10,("hid_get_udata: loc %d/%d = %lu\n", hpos, hsize, data));
return (data);
Home |
Main Index |
Thread Index |
Old Index