windows: fix broken bus number lookup
authorPete Batard <pete@akeo.ie>
Thu, 5 Mar 2015 22:16:39 +0000 (22:16 +0000)
committerPete Batard <pete@akeo.ie>
Thu, 5 Mar 2015 22:18:13 +0000 (22:18 +0000)
* 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

libusb/os/windows_usb.c
libusb/version_nano.h

index f100759..098543b 100644 (file)
@@ -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;
index 4414de6..a8bf988 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 10966
+#define LIBUSB_NANO 10967