A buggy virtual USB device driver can cause the device enumeration
process to fail during the init_device() function when trying to
determine the bus number of the device. Guard against this by checking
that the ancestor device was actually found and skipping the bogus
device when there is no ancestor.
Closes #491
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
for (depth = 1; bus_number == 0; depth++) {
tmp_dev = get_ancestor(ctx, devinst, &devinst);
+ if (tmp_dev == NULL) {
+ usbi_warn(ctx, "ancestor for device '%s' not found at depth %u", priv->dev_id, depth);
+ return LIBUSB_ERROR_NO_DEVICE;
+ }
if (tmp_dev->bus_number != 0) {
bus_number = tmp_dev->bus_number;
tmp_priv = usbi_get_device_priv(tmp_dev);
-#define LIBUSB_NANO 11535
+#define LIBUSB_NANO 11536