summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pete@akeo.ie>2015-03-05 22:16:39 +0000
committerPete Batard <pete@akeo.ie>2015-03-05 22:18:13 +0000
commit56aa10682477ac5b2c80e19842772c38749be1f1 (patch)
tree3608ac754ca207848e267b10a4f915f5e161c7b8
parentc7401ca1e0cb00b470fdb27416a5fe51b14281de (diff)
downloadlibusb-56aa10682477ac5b2c80e19842772c38749be1f1.tar.gz
windows: fix broken bus number lookup
* The current ancestry lookup for bus number stopped at the first non-enumerated grandparent device instead of continuing up to the HCD. * Issue reported by Daniel Pfeffer
-rw-r--r--libusb/os/windows_usb.c7
-rw-r--r--libusb/version_nano.h2
2 files changed, 6 insertions, 3 deletions
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index f100759..098543b 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -1226,6 +1226,7 @@ static int init_device(struct libusb_device* dev, struct libusb_device* parent_d
struct windows_device_priv *priv, *parent_priv;
struct libusb_context *ctx;
struct libusb_device* tmp_dev;
+ unsigned long tmp_id;
unsigned i;
if ((dev == NULL) || (parent_dev == NULL)) {
@@ -1243,8 +1244,10 @@ static int init_device(struct libusb_device* dev, struct libusb_device* parent_d
// If that's the case, lookup the ancestors to set the bus number
if (parent_dev->bus_number == 0) {
for (i=2; ; i++) {
- tmp_dev = usbi_get_device_by_session_id(ctx, get_ancestor_session_id(devinst, i));
- if (tmp_dev == NULL) break;
+ tmp_id = get_ancestor_session_id(devinst, i);
+ if (tmp_id == 0) break;
+ tmp_dev = usbi_get_device_by_session_id(ctx, tmp_id);
+ if (tmp_dev == NULL) continue;
if (tmp_dev->bus_number != 0) {
usbi_dbg("got bus number from ancestor #%d", i);
parent_dev->bus_number = tmp_dev->bus_number;
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 4414de6..a8bf988 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10966
+#define LIBUSB_NANO 10967