[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[win-pv-devel] [PATCH] Fix list walking in hash_table.c



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@xxxxxxxxxx>
Reported-by: Rafal Wojdyla <omeg@xxxxxxxxxxxxxxxxxxxxxx>
---
 src/xenbus/hash_table.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/xenbus/hash_table.c b/src/xenbus/hash_table.c
index c7c6101..b271abd 100644
--- a/src/xenbus/hash_table.c
+++ b/src/xenbus/hash_table.c
@@ -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)
-- 
2.1.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.