summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIdo Yariv <ido@wizery.com>2020-05-20 16:23:11 -0400
committerChris Dickens <christopher.a.dickens@gmail.com>2020-06-09 10:28:41 -0700
commit0003e606175e344d463a9af73658cab5c01d6286 (patch)
tree300dcae1071eaba8974f69d7d8562febf65dbf52
parent26611eaa494ed9e077b5b0e1f999f5ae377de958 (diff)
downloadlibusb-0003e606175e344d463a9af73658cab5c01d6286.tar.gz
darwin: Fix stale descriptor information post reset
As part of the recent removal of the backend get_device_descriptor() function, the darwin backend was modified to update the cached device_descriptor when a new device is processed. However, this wasn't done for cases where the device is reused rather than allocated. This could potentially result in getting stale data when using the device following a reset. In addition, when the device is reused, its session ID should be kept up-to-date in the cached devices list, so it could be found in subsequent resets. Closes #733 Signed-off-by: Ido Yariv <ido@wizery.com> Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
-rw-r--r--libusb/os/darwin_usb.c10
-rw-r--r--libusb/version_nano.h2
2 files changed, 7 insertions, 5 deletions
diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c
index 58944be..ec5225e 100644
--- a/libusb/os/darwin_usb.c
+++ b/libusb/os/darwin_usb.c
@@ -1115,14 +1115,16 @@ static enum libusb_error process_new_device (struct libusb_context *ctx, struct
dev->bus_number = cached_device->location >> 24;
assert(cached_device->address <= UINT8_MAX);
dev->device_address = (uint8_t)cached_device->address;
- static_assert(sizeof(dev->device_descriptor) == sizeof(cached_device->dev_descriptor),
- "mismatch between libusb and IOKit device descriptor sizes");
- memcpy(&dev->device_descriptor, &cached_device->dev_descriptor, LIBUSB_DT_DEVICE_SIZE);
- usbi_localize_device_descriptor(&dev->device_descriptor);
} else {
priv = usbi_get_device_priv(dev);
}
+ static_assert(sizeof(dev->device_descriptor) == sizeof(cached_device->dev_descriptor),
+ "mismatch between libusb and IOKit device descriptor sizes");
+ memcpy(&dev->device_descriptor, &cached_device->dev_descriptor, LIBUSB_DT_DEVICE_SIZE);
+ usbi_localize_device_descriptor(&dev->device_descriptor);
+ dev->session_data = cached_device->session;
+
if (cached_device->parent_session > 0) {
dev->parent_dev = usbi_get_device_by_session_id (ctx, (unsigned long) cached_device->parent_session);
} else {
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 38dbc26..cdfeb4b 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11516
+#define LIBUSB_NANO 11517