Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

futex: fix init order

When the futex init code fails to initialize the futex pseudo file system it
returns early without initializing the hash queues. Should the boot succeed
then a futex syscall which tries to enqueue a waiter on the hashqueue will
crash due to the unitilialized plist heads.

Initialize the hash queues before the filesystem.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Ingo Molnar <mingo@elte.hu>
Cc: Lennert Buytenhek <buytenh@wantstofly.org>
Cc: Riku Voipio <riku.voipio@movial.fi>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Thomas Gleixner and committed by
Linus Torvalds
3e4ab747 43fe105a

+7 -5
+7 -5
kernel/futex.c
··· 2145 2145 2146 2146 static int __init init(void) 2147 2147 { 2148 - int i = register_filesystem(&futex_fs_type); 2148 + int i; 2149 2149 2150 + for (i = 0; i < ARRAY_SIZE(futex_queues); i++) { 2151 + plist_head_init(&futex_queues[i].chain, &futex_queues[i].lock); 2152 + spin_lock_init(&futex_queues[i].lock); 2153 + } 2154 + 2155 + i = register_filesystem(&futex_fs_type); 2150 2156 if (i) 2151 2157 return i; 2152 2158 ··· 2162 2156 return PTR_ERR(futex_mnt); 2163 2157 } 2164 2158 2165 - for (i = 0; i < ARRAY_SIZE(futex_queues); i++) { 2166 - plist_head_init(&futex_queues[i].chain, &futex_queues[i].lock); 2167 - spin_lock_init(&futex_queues[i].lock); 2168 - } 2169 2159 return 0; 2170 2160 } 2171 2161 __initcall(init);