summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Batard <pbatard@gmail.com>2011-03-08 14:23:53 +0000
committerPete Batard <pbatard@gmail.com>2011-03-08 14:23:53 +0000
commit5a0c8efc94aeb1af56fa36085269e70450de0085 (patch)
tree6b16b24a050009c792d981b07690ccb129764856
parent5c2824c46432f3d3c9669c3029bae934d91ab75e (diff)
downloadlibusb-5a0c8efc94aeb1af56fa36085269e70450de0085.tar.gz
[enum] fixed short device initialization
* some devices (eg. hubs) could fail to be properly setup because of short initialization added in pbr333 (memleak issue) * use device_address instead of bus_number for check
-rw-r--r--libusb/os/windows_usb.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c
index 0dd5fb1..5f5b3b7 100644
--- a/libusb/os/windows_usb.c
+++ b/libusb/os/windows_usb.c
@@ -1020,10 +1020,6 @@ static int init_device(struct libusb_device* dev, struct libusb_device* parent_d
if ((dev == NULL) || (parent_dev == NULL)) {
return LIBUSB_ERROR_NOT_FOUND;
}
- if (dev->bus_number != 0) {
- // Device has already been initialized
- return LIBUSB_SUCCESS;
- }
priv = __device_priv(dev);
parent_priv = __device_priv(parent_dev);
if (parent_priv->apib->id != USB_API_HUB) {
@@ -1054,8 +1050,12 @@ static int init_device(struct libusb_device* dev, struct libusb_device* parent_d
priv->depth = parent_priv->depth + 1;
priv->parent_dev = parent_dev;
dev->parent_dev = parent_dev;
- memset(&conn_info, 0, sizeof(conn_info));
+ // If the device address is already set, we can stop here
+ if (dev->device_address != 0) {
+ return LIBUSB_SUCCESS;
+ }
+ memset(&conn_info, 0, sizeof(conn_info));
if (priv->depth != 0) { // Not a HCD hub
handle = CreateFileA(parent_priv->path, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
FILE_FLAG_OVERLAPPED, NULL);