From 56aa10682477ac5b2c80e19842772c38749be1f1 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Thu, 5 Mar 2015 22:16:39 +0000 Subject: [PATCH] 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 --- libusb/os/windows_usb.c | 7 +++++-- libusb/version_nano.h | 2 +- 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 -- 2.7.4