kern/63837: [USB/patch] hid_is_collection() only looks up the first
item
Nicola Vitale
nivit at email.it
Sat Mar 6 05:20:18 PST 2004
>Number: 63837
>Category: kern
>Synopsis: [USB/patch] hid_is_collection() only looks for the first item
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat Mar 06 05:20:17 PST 2004
>Closed-Date:
>Last-Modified:
>Originator: Nicola Vitale
>Release: FreeBSD 4.9-STABLE i386
>Organization:
>Environment:
System: FreeBSD psyllobora.domo.sva 4.9-STABLE FreeBSD 4.9-STABLE #7: Thu Feb 26 21:34:04 CET 2004 root at psyllobora.domo.sva:/usr/obj/usr/src/sys/Psyllobora i386
>Description:
The function hid_is_collection, in this file:
__FBSDID("$FreeBSD: src/sys/dev/usb/hid.c,v 1.11.2.7 2004/03/01 00:07:21 julian Exp $");
only looks for the first item and does not "parse" the whole of
Report Descriptor, so if the usage, which you are checking, is
not the first the function always returns 0.
>How-To-Repeat:
For example, using an USB digitizer, modify the ums(4)
driver, so that it looks for
HID_USAGE2(HUP_DIGITIZERS, HUP_DIGITIZER)
(HUP_DIGITIZER==0x01, see HID Usages Tables),
etc, etc,...
>Fix:
A possible solution:
--- hid.c.patch begins here ---
--- src/sys/dev/usb/hid.c Mon Mar 1 01:07:21 2004
+++ src/sys/dev/usb/hid.c.new Sat Mar 6 13:16:25 2004
@@ -441,15 +441,20 @@
{
struct hid_data *hd;
struct hid_item hi;
- int err;
+ int err, found;
hd = hid_start_parse(desc, size, hid_input);
if (hd == NULL)
return (0);
- err = hid_get_item(hd, &hi) &&
- hi.kind == hid_collection &&
- hi.usage == usage;
+ found = 0;
+ while((err = hid_get_item(hd, &hi)) > 0)
+ if (hi.kind == hid_collection && hi.usage == usage) {
+ found = 1;
+ break;
+ }
+
hid_end_parse(hd);
- return (err);
+
+ return (found);
}
--- hid.c.patch ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list