mirror of
https://github.com/RPCS3/libusb.git
synced 2026-07-21 00:16:04 -04:00
Windows: Fix false assertion failure message during enumeration
Commit 1d54ee1b66 addressed a device
reference leak but introduced a false warning message that occurs
for devices detected in early enumeration passes (e.g. hubs). The
assertion is meant to warn of a mismatch between parent devices but
fails to account for the fact that some devices that are allocated
early do not have a parent device assigned until the later
enumeration passes.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
This commit is contained in:
@@ -1514,16 +1514,20 @@ static int windows_get_device_list(struct libusb_context *ctx, struct discovered
|
||||
if (dev == NULL)
|
||||
LOOP_BREAK(LIBUSB_ERROR_NO_MEM);
|
||||
|
||||
windows_device_priv_init(dev);
|
||||
priv = windows_device_priv_init(dev);
|
||||
} else {
|
||||
usbi_dbg("found existing device for session [%lX] (%u.%u)",
|
||||
session_id, dev->bus_number, dev->device_address);
|
||||
if (_device_priv(dev)->parent_dev != parent_dev) {
|
||||
usbi_err(ctx,"program assertion failed - existing device should share parent");
|
||||
} else {
|
||||
// We hold a reference to parent_dev instance, but this device already
|
||||
// has a parent_dev reference (only one per child)
|
||||
libusb_unref_device(parent_dev);
|
||||
|
||||
priv = _device_priv(dev);
|
||||
if (priv->parent_dev != NULL) {
|
||||
if (priv->parent_dev != parent_dev) {
|
||||
usbi_err(ctx, "program assertion failed - existing device should share parent");
|
||||
} else {
|
||||
// We hold a reference to parent_dev instance, but this device already
|
||||
// has a parent_dev reference (only one per child)
|
||||
libusb_unref_device(parent_dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1537,7 +1541,6 @@ static int windows_get_device_list(struct libusb_context *ctx, struct discovered
|
||||
LOOP_BREAK(LIBUSB_ERROR_NO_MEM);
|
||||
}
|
||||
}
|
||||
priv = _device_priv(dev);
|
||||
}
|
||||
|
||||
// Setup device
|
||||
|
||||
@@ -224,7 +224,7 @@ static inline struct windows_device_priv *_device_priv(struct libusb_device *dev
|
||||
return (struct windows_device_priv *)dev->os_priv;
|
||||
}
|
||||
|
||||
static inline void windows_device_priv_init(struct libusb_device *dev)
|
||||
static inline struct windows_device_priv *windows_device_priv_init(struct libusb_device *dev)
|
||||
{
|
||||
struct windows_device_priv *p = _device_priv(dev);
|
||||
int i;
|
||||
@@ -247,6 +247,8 @@ static inline void windows_device_priv_init(struct libusb_device *dev)
|
||||
p->usb_interface[i].endpoint = NULL;
|
||||
p->usb_interface[i].restricted_functionality = false;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
static inline void windows_device_priv_release(struct libusb_device *dev)
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define LIBUSB_NANO 11108
|
||||
#define LIBUSB_NANO 11109
|
||||
|
||||
Reference in New Issue
Block a user