From 911da8987f06fe761d94ed6b30ee6b7c44d604a1 Mon Sep 17 00:00:00 2001 From: mav Date: Wed, 1 Feb 2012 20:12:44 +0000 Subject: [PATCH 090/175] Fix NULL dereference panic on attempt to turn off (on system shutdown) disconnected swap device. This is quick and imperfect solution, as swap device will still be opened and GEOM will not be able to destroy it. Proper solution would be to automatically turn off and close disconnected swap device, but with existing code it will cause panic if there is at least one page on device, even if it is unimportant page of the user-level process. It needs some work. Reviewed by: kib@ MFC after: 1 week git-svn-id: http://svn.freebsd.org/base/head@230877 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f (cherry picked from commit 1fa1fe2fb2342e9a2e95d3cbc35b7e7121257a1a) Signed-off-by: Xin Li --- sys/vm/swap_pager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 058c155..ec165fd 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -2521,7 +2521,7 @@ swapgeom_orphan(struct g_consumer *cp) mtx_lock(&sw_dev_mtx); TAILQ_FOREACH(sp, &swtailq, sw_list) if (sp->sw_id == cp) - sp->sw_id = NULL; + sp->sw_flags |= SW_CLOSING; mtx_unlock(&sw_dev_mtx); } -- 1.7.9.4