Commit 280dc4bf01bc9fe1dfe212f27644855bab936d2d

Con Kolivas 2013-10-14T00:54:05

Lock mutex before second pthread_cond_wait in usbutils to prevent a race.

1
2
3
4
5
6
7
8
9
10
11
12
diff --git a/usbutils.c b/usbutils.c
index 00bfcce..2ab34d4 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -2237,6 +2237,7 @@ static int callback_wait(struct usb_transfer *ut, int *transferred, unsigned int
 		libusb_cancel_transfer(transfer);
 
 		/* Now wait for the callback function to be invoked. */
+		mutex_lock(&ut->mutex);
 		pthread_cond_wait(&ut->cond, &ut->mutex);
 	}
 	ret = transfer->status;