Commit 2108cceb6a4751b0ca885333c90de9040ee87e7d

Con Kolivas 2014-02-15T14:45:58

Break out of linked list loop in remove_in_use in case we've gone over the whole list.

diff --git a/usbutils.c b/usbutils.c
index 5d8cf7c..efe46e3 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -1337,13 +1337,16 @@ static void __remove_in_use(uint8_t bus_number, uint8_t device_address, bool bla
 			break;
 		}
 		in_use_tmp = in_use_tmp->next;
+		if (in_use_tmp == *head)
+			break;
 	}
 
 	mutex_unlock(&cgusb_lock);
 
-	if (!found)
+	if (!found) {
 		applog(LOG_ERR, "FAIL: USB remove not already in use (%d:%d)",
 				(int)bus_number, (int)device_address);
+	}
 }
 
 static void remove_in_use(uint8_t bus_number, uint8_t device_address)