Index: linux-2.6.17-rc5-mm2/mm/swapfile.c =================================================================== --- linux-2.6.17-rc5-mm2.orig/mm/swapfile.c 2006-06-01 10:03:07.127259731 -0700 +++ linux-2.6.17-rc5-mm2/mm/swapfile.c 2006-06-05 13:39:26.592396422 -0700 @@ -1392,24 +1392,15 @@ asmlinkage long sys_swapon(const char __ if (!(p->flags & SWP_USED)) break; error = -EPERM; - /* - * Test if adding another swap device is possible. There are - * two limiting factors: 1) the number of bits for the swap - * type swp_entry_t definition and 2) the number of bits for - * the swap type in the swap ptes as defined by the different - * architectures. To honor both limitations a swap entry - * with swap offset 0 and swap type ~0UL is created, encoded - * to a swap pte, decoded to a swp_entry_t again and finally - * the swap type part is extracted. This will mask all bits - * from the initial ~0UL that can't be encoded in either the - * swp_entry_t or the architecture definition of a swap pte. - */ - if (type > swp_type(pte_to_swp_entry(swp_entry_to_pte(swp_entry(~0UL,0))))) { - spin_unlock(&swap_lock); - goto out; - } - if (type >= nr_swapfiles) + + if (type >= nr_swapfiles) { + if (nr_swapfiles >= MAX_SWAPFILES) { + spin_unlock(&swap_lock); + return -E2BIG; + } nr_swapfiles = type+1; + } + INIT_LIST_HEAD(&p->extent_list); p->flags = SWP_USED; p->swap_file = NULL;