All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org
Cc: Will Deacon <will.deacon@arm.com>
Subject: [PATCH] kvmtool: devices.c: Update parent when inserting into rbtree
Date: Wed, 15 Jun 2016 11:59:08 +0100	[thread overview]
Message-ID: <1465988348-968-1-git-send-email-james.morse@arm.com> (raw)

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

                 reply	other threads:[~2016-06-15 10:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1465988348-968-1-git-send-email-james.morse@arm.com \
    --to=james.morse@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.