[PATCH mmotm] fix to swap_info-include-first_swap_extent-fix.patch

From: Hugh Dickins
Date: Tue Nov 03 2009 - 17:19:54 EST


Sorry, just noticed what the diff contexts don't show: Jiri's patch
is initializing p->first_swap_extent.list at a point before p has
been decided - we may kfree that newly allocated p and go on to
reuse an existing free entry for p.

Now, the patch is not actually wrong: an existing free entry will have
a good empty first_swap_extent.list; but it looks suspicious, it seems
strange to initialize a field in something we're about to kfree, and
I'd rather we put that initialization back to where it was in 2.6.32.

Signed-off-by: Hugh Dickins <hugh.dickins@xxxxxxxxxxxxx>
---

mm/swapfile.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- mmotm/mm/swapfile.c 2009-11-03 18:05:36.000000000 +0000
+++ linux/mm/swapfile.c 2009-11-03 18:08:26.000000000 +0000
@@ -1768,7 +1768,6 @@ SYSCALL_DEFINE2(swapon, const char __use
kfree(p);
goto out;
}
- INIT_LIST_HEAD(&p->first_swap_extent.list);
if (type >= nr_swapfiles) {
p->type = type;
swap_info[type] = p;
@@ -1787,6 +1786,7 @@ SYSCALL_DEFINE2(swapon, const char __use
* would be relying on p->type to remain valid.
*/
}
+ INIT_LIST_HEAD(&p->first_swap_extent.list);
p->flags = SWP_USED;
p->next = -1;
spin_unlock(&swap_lock);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/