]> xenbits.xensource.com Git - people/pauldu/xenbus.git/commitdiff
Fix list walking in hash_table.c
authorPaul Durrant <paul.durrant@citrix.com>
Thu, 10 Sep 2015 09:05:01 +0000 (10:05 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Thu, 10 Sep 2015 09:05:01 +0000 (10:05 +0100)
Neither HashTableLookup() nor HashTableRemove() update the iterator in their
attempted list walks, leading to an endless spin. This patch changes the
while loops to for loops and fixes the problem.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reported-by: Rafal Wojdyla <omeg@invisiblethingslab.com>
src/xenbus/hash_table.c

index c7c6101001bc5b0843784b55ea387e75de065583..b271abdfee2f44eb0c8ae58fbccc2b5892c321c7 100644 (file)
@@ -249,8 +249,9 @@ HashTableRemove(
     
     HashTableBucketLock(Bucket, TRUE, &Irql);
 
-    ListEntry = Bucket->List.Flink;
-    while (ListEntry != &Bucket->List) {
+    for (ListEntry = Bucket->List.Flink;
+         ListEntry != &Bucket->List;
+         ListEntry = ListEntry->Flink) {
         Node = CONTAINING_RECORD(ListEntry, XENBUS_HASH_TABLE_NODE, ListEntry);
 
         if (Node->Key == Key)
@@ -294,8 +295,9 @@ HashTableLookup(
     
     HashTableBucketLock(Bucket, FALSE, &Irql);
 
-    ListEntry = Bucket->List.Flink;
-    while (ListEntry != &Bucket->List) {
+    for (ListEntry = Bucket->List.Flink;
+         ListEntry != &Bucket->List;
+         ListEntry = ListEntry->Flink) {
         Node = CONTAINING_RECORD(ListEntry, XENBUS_HASH_TABLE_NODE, ListEntry);
 
         if (Node->Key == Key)