• Jiri Slaby's avatar
    Double swapon on a device causes a crash: · f27e5313
    Jiri Slaby authored
    BUG: unable to handle kernel NULL pointer dereference at (null)
    IP: [<ffffffff810af160>] sys_swapon+0x1f0/0xc60
    PGD 1dc0b067 PUD 1dc09067 PMD 0
    Oops: 0000 [#1] SMP
    last sysfs file:
    CPU 1
    Modules linked in:
    Pid: 562, comm: swapon Tainted: G        W  2.6.32-rc5-mm1_64 #867
    RIP: 0010:[<ffffffff810af160>]  [<ffffffff810af160>] sys_swapon+0x1f0/0xc60
    ...
    
    It is due to swap_info_struct->first_swap_extent.list not being
    initialized. ->next is NULL in such a situation and
    destroy_swap_extents fails to iterate over the list with the BUG
    above.
    
    Introduced by swap_info-include-first_swap_extent.patch. Revert the
    INIT_LIST_HEAD move.
    Signed-off-by: default avatarJiri Slaby <jirislaby@gmail.com>
    Acked-by: default avatarHugh Dickins <hugh.dickins@tiscali.co.uk>
    Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
    Cc: Rik van Riel <riel@redhat.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    f27e5313
swapfile.c 56.4 KB