From 8b332a8ee5912d72cba40ac2a66741d7e64eb424 Mon Sep 17 00:00:00 2001 From: Paul Durrant Date: Thu, 10 Sep 2015 10:05:01 +0100 Subject: [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 Reported-by: Rafal Wojdyla --- 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.39.5