Commit 492636a81f25dd6e4220f43f9ce88f268c351f89

Con Kolivas 2014-02-14T21:36:58

Prevent recursive loop in __is_in_use linked list walking.

diff --git a/miner.h b/miner.h
index f35cfe5..334ba77 100644
--- a/miner.h
+++ b/miner.h
@@ -686,7 +686,7 @@ extern void _quit(int status);
  * So, e.g. use it to track down a deadlock - after a reproducable deadlock occurs
  * ... Of course if the API code itself deadlocks, it wont help :)
  */
-#define LOCK_TRACKING 0
+#define LOCK_TRACKING 1
 
 #if LOCK_TRACKING
 enum cglock_typ {
diff --git a/usbutils.c b/usbutils.c
index bb4c997..5d8cf7c 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -1243,6 +1243,8 @@ static bool __is_in_use(uint8_t bus_number, uint8_t device_address)
 			break;
 		}
 		in_use_tmp = in_use_tmp->next;
+		if (in_use_tmp == in_use_head)
+			break;
 	}
 	in_use_tmp = blacklist_head;
 	while (in_use_tmp) {
@@ -1252,6 +1254,8 @@ static bool __is_in_use(uint8_t bus_number, uint8_t device_address)
 			break;
 		}
 		in_use_tmp = in_use_tmp->next;
+		if (in_use_tmp == blacklist_head)
+			break;
 	}
 
 	return ret;