]> git.karo-electronics.de Git - karo-tx-linux.git/commit
kvm tools: fix rbtree-interval search
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Mon, 29 Oct 2012 12:12:57 +0000 (14:12 +0200)
committerPekka Enberg <penberg@kernel.org>
Wed, 31 Oct 2012 07:34:15 +0000 (09:34 +0200)
commitf456d184177293de91edf163c9177d273183a149
treec3a658a356b75a3522c390865193d0d132704a10
parent58bd23dd3bc3d74dc7064ef7a2d08e15e74c295b
kvm tools: fix rbtree-interval search

I've noticed message on kvm exit:

  Warning: serial8250__exit failed.

kvm tool is not able to remove ioport range which was added previously.

The issue is caused by bug in rbtree-interval. Search algorithm in
rb_int_search_single() expects correct value of max_high. But the tree
can contain leaf nodes, which never were updated by propagate_callback().
For this kind of nodes high_max will be 0 and we will not be able to
find and remove them.

Let's initialize max_high on RB_INT_INIT() time.

Fixing this bug makes other bug visible: propagate_callback() can be
called for empty tree: node == NULL. The callback is not ready for empty
tree. Let's fix that as well.

Tested-by: William Dauchy <william@gandi.net>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/include/kvm/rbtree-interval.h
tools/kvm/util/rbtree-interval.c