usb/79190: usbd_get_string_desc() is called with the wrong lang ID
Hans Petter Selasky
hselasky at c2i.net
Thu Mar 24 03:30:03 PST 2005
>Number: 79190
>Category: usb
>Synopsis: usbd_get_string_desc() is called with the wrong lang ID
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: freebsd-usb
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Thu Mar 24 11:30:02 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator: HPS
>Release: FreeBSD 6.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD 6.0-CURRENT FreeBSD 6.0-CURRENT #45: Mon Mar 21 15:40:17 CET
2005 root@:/usr/obj/usr/src/sys/custom i386
>Description:
In the file "/sys/dev/usb/uhub.c" in the function "uhub_child_pnpinfo_str"
usbd_get_string_desc() is called with the wrong language parameter (0). This
[invalid] request causes some devices not to work at all!
>How-To-Repeat:
>Fix:
The solution is to call usbd_get_string() which will setup the correct
language parameter, instead of usbd_get_string_desc()
--- uhub.c.ref Thu Mar 24 12:07:36 2005
+++ uhub.c Thu Mar 24 12:15:12 2005
@@ -664,13 +664,11 @@
struct uhub_softc *sc = device_get_softc(cbdev);
usbd_device_handle devhub = sc->sc_hub;
usbd_device_handle dev;
- usb_string_descriptor_t us;
struct usbd_interface *iface;
char serial[128];
int nports;
int port;
- int i, j, size;
- int err;
+ int i;
nports = devhub->hub->hubdesc.bNbrPorts;
for (port = 0; port < nports; port++) {
@@ -688,18 +686,10 @@
return (0);
found_dev:
- j = 0;
+ serial[0] = '\0';
if (dev->ddesc.iSerialNumber != 0) {
- err = usbd_get_string_desc(dev, dev->ddesc.iSerialNumber, 0,
- &us, &size);
- if (err == 0) {
- do {
- serial[j] = UGETW(us.bString[j]);
- j++;
- } while (j < ((us.bLength - 2) / 2));
- }
+ (void) usbd_get_string(dev, dev->ddesc.iSerialNumber, &serial[0]);
}
- serial[j] = '\0';
if (dev->ifacenums == NULL) {
snprintf(buf, buflen, "vendor=0x%04x product=0x%04x "
"devclass=0x%02x devsubclass=0x%02x "
Here is another bugfix:
*** sys/dev/usb/umass.c.ref Wed Nov 17 18:56:27 2004
--- sys/dev/usb/umass.c Thu Dec 2 12:39:51 2004
***************
*** 110,115 ****
--- 110,116 ----
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/module.h>
+ #include <sys/malloc.h>
#include <sys/bus.h>
#include <sys/sysctl.h>
***************
*** 928,934 ****
#endif
if (sc->quirks & ALT_IFACE_1) {
! err = usbd_set_interface(0, 1);
if (err) {
DPRINTF(UDMASS_USB, ("%s: could not switch to "
"Alt Interface %d\n",
--- 929,935 ----
#endif
if (sc->quirks & ALT_IFACE_1) {
! err = usbd_set_interface(uaa->iface, 1);
if (err) {
DPRINTF(UDMASS_USB, ("%s: could not switch to "
"Alt Interface %d\n",
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-usb
mailing list