All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kvmtool: devices.c: Update parent when inserting into rbtree
@ 2016-06-15 10:59 James Morse
  0 siblings, 0 replies; only message in thread
From: James Morse @ 2016-06-15 10:59 UTC (permalink / raw)
  To: kvmarm, kvm; +Cc: Will Deacon

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>
---
 devices.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/devices.c b/devices.c
index b560a59..a7c666a 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)
-- 
2.8.0.rc3

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-06-15 10:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-15 10:59 [PATCH] kvmtool: devices.c: Update parent when inserting into rbtree James Morse

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.