If we write the remove event to the pipe before doing the list_del,
in theory another thread can process the event and unref the device before
it has been removed from usb_devs.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
dev->attached = 0;
usbi_mutex_unlock(&dev->lock);
+ usbi_mutex_lock(&ctx->usb_devs_lock);
+ list_del(&dev->list);
+ usbi_mutex_unlock(&ctx->usb_devs_lock);
+
/* Signal that an event has occurred for this device if we support hotplug AND
* the hotplug pipe is ready. This prevents an event from getting raised during
* initial enumeration. libusb_handle_events will take care of dereferencing the
usbi_err(DEVICE_CTX(dev), "error writing hotplug message");
}
}
-
- usbi_mutex_lock(&ctx->usb_devs_lock);
- list_del(&dev->list);
- usbi_mutex_unlock(&ctx->usb_devs_lock);
}
/* Perform some final sanity checks on a newly discovered device. If this
-#define LIBUSB_NANO 10812
+#define LIBUSB_NANO 10813