cgroups: if you list_empty() a head then don't list_del() it
authorPhil Carmody <ext-phil.2.carmody@nokia.com>
Tue, 22 Mar 2011 23:30:13 +0000 (16:30 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sun, 27 Mar 2011 18:35:43 +0000 (11:35 -0700)
commit9432a739a5063919c14c15c722c653a16d797474
tree099464fced9a6e6da3587cee2b8916abe8fe86ec
parent715335d9edcad02a3502a609290229ce179a62a1
cgroups: if you list_empty() a head then don't list_del() it

commit 8d2587970b8bdf7c8d9208e3f4bb93182aef1a0f upstream.

list_del() leaves poison in the prev and next pointers.  The next
list_empty() will compare those poisons, and say the list isn't empty.
Any list operations that assume the node is on a list because of such a
check will be fooled into dereferencing poison.  One needs to INIT the
node after the del, and fortunately there's already a wrapper for that -
list_del_init().

Some of the dels are followed by deallocations, so can be ignored, and one
can be merged with an add to make a move.  Apart from that, I erred on the
side of caution in making nodes list_empty()-queriable.

Signed-off-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
Reviewed-by: Paul Menage <menage@google.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
kernel/cgroup.c