Commit e40c5f61d80a3e87974294b483eecd7366285b8f

Con Kolivas 2014-05-15T14:33:58

Add hacky workaround for double list removal race in libusb

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/compat/libusb-1.0/libusb/io.c b/compat/libusb-1.0/libusb/io.c
index f488478..d19102a 100644
--- a/compat/libusb-1.0/libusb/io.c
+++ b/compat/libusb-1.0/libusb/io.c
@@ -1478,7 +1478,10 @@ int usbi_handle_transfer_completion(struct usbi_transfer *itransfer,
 	 * the shortest timeout. */
 
 	usbi_mutex_lock(&ctx->flying_transfers_lock);
-	list_del(&itransfer->list);
+	/* FIXME: Sanity check for some race where this entry has already been
+	 * removed! */
+	if (status == LIBUSB_TRANSFER_NO_DEVICE && (&itransfer->list)->next)
+		list_del(&itransfer->list);
 	if (usbi_using_timerfd(ctx)) {
 		r = arm_timerfd_for_next_timeout(ctx);
 		if (0 == r)