From: Wen Congyang <wency@cn.fujitsu.com>
Date: Mon, 17 Sep 2012 21:08:55 +0000 (-0700)
Subject: memory hotplug: reset pgdat->kswapd to NULL if creating kernel thread fails
X-Git-Tag: v3.6-rc7~34^2~12
X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=18b48d5873a6fc8e0e6044ddb572fcda26988f19;p=users%2Fjedix%2Flinux-maple.git

memory hotplug: reset pgdat->kswapd to NULL if creating kernel thread fails

If kthread_run() fails, pgdat->kswapd contains errno.  When we stop this
thread, we only check whether pgdat->kswapd is NULL and access it.  If
it contains errno, it will cause page fault.  Reset pgdat->kswapd to
NULL when creating kernel thread fails can avoid this problem.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Reviewed-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 8d01243d9560..99b434b674c0 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -3102,6 +3102,7 @@ int kswapd_run(int nid)
 		/* failure at boot is fatal */
 		BUG_ON(system_state == SYSTEM_BOOTING);
 		printk("Failed to start kswapd on node %d\n",nid);
+		pgdat->kswapd = NULL;
 		ret = -1;
 	}
 	return ret;