aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Morse <james.morse@arm.com>2016-06-15 11:59:08 +0100
committerWill Deacon <will.deacon@arm.com>2016-06-15 12:36:54 +0100
commitb6dcc46671b81d443f811eaef8c148929afe8f59 (patch)
tree13a14a206268e6c2e53c79db4d4f38ad7c7eecdb
parente4f04b1997082a93d8c7d58fe6666168c58b692c (diff)
downloadkvmtool-b6dcc46671b81d443f811eaef8c148929afe8f59.tar.gz
kvmtool: devices.c: Update parent when inserting into rbtree
When walking the devices rbtree to insert a node, we must keep track of the parent node when we descend. If we skip this step, we always insert new nodes with a NULL parent, bypassing __rb_insert()s rebalance code. Things get worse when we come to walk the tree, as we can't move up a level. This isn't a problem in practice, as all devices appear to be inserted in-order, so our rbtree is actually a monochrome linked list. Signed-off-by: James Morse <james.morse@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r--devices.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/devices.c b/devices.c
index b560a599..a7c666a7 100644
--- a/devices.c
+++ b/devices.c
@@ -45,6 +45,7 @@ int device__register(struct device_header *dev)
int num = rb_entry(*node, struct device_header, node)->dev_num;
int result = dev->dev_num - num;
+ parent = *node;
if (result < 0)
node = &((*node)->rb_left);
else if (result > 0)