rbtree: fix incorrect rbtree node insertion in fs/proc/proc_sysctl.c
authorMichel Lespinasse <[email protected]>
Mon, 8 Oct 2012 23:30:35 +0000 (16:30 -0700)
committerLinus Torvalds <[email protected]>
Tue, 9 Oct 2012 07:22:32 +0000 (16:22 +0900)
commitea5272f5c94fb2ee62f4f15a5b88eef6184cd506
tree819666fc929bcc50c434feba5f99beb44ed1ac7d
parent4c199a93a2d36b277a9fd209a0f2793f8460a215
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 <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Acked-by: David Woodhouse <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Daniel Santos <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
fs/proc/proc_sysctl.c