From: Michel Lespinasse Date: Fri, 28 Sep 2012 00:19:24 +0000 (+1000) Subject: rbtree: fix incorrect rbtree node insertion in fs/proc/proc_sysctl.c X-Git-Tag: next-20121004~1^2~308 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=f0994c29abaf5850cd599ccc090b5f216801267a;p=karo-tx-linux.git rbtree: fix incorrect rbtree node insertion in fs/proc/proc_sysctl.c The recently added code to use rbtrees in sysctl did not follow the proper rbtree interface on insertion - it was calling rb_link_node() which inserts a new node into the binary tree, but missed the call to rb_insert_color() which properly balances the rbtree and establishes all expected rbtree invariants. I found out about this only because faulty commit also used rb_init_node(), which I am removing within this patchset. But I think it's an easy mistake to make, and it makes me wonder if we should change the rbtree API so that insertions would be done with a single rb_insert() call (even if its implementation could still inline the rb_link_node() part and call a private __rb_insert_color function to do the rebalancing). Signed-off-by: Michel Lespinasse Cc: Andrea Arcangeli Acked-by: David Woodhouse Cc: Rik van Riel Cc: Peter Zijlstra Cc: Daniel Santos Cc: Jens Axboe Cc: "Eric W. Biederman" Signed-off-by: Andrew Morton --- diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 080855bb6b74..a42243fa9cdb 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -142,6 +142,7 @@ static int insert_entry(struct ctl_table_header *head, struct ctl_table *entry) } rb_link_node(node, parent, p); + rb_insert_color(node, &head->parent->root); return 0; }