From 8f12d83ad9208fd015e6d43d2fae3f71f5f440d6 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Wed, 1 Feb 2012 20:12:44 +0000 Subject: [PATCH] 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 --- 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 dba624b72513..93621a9513d0 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); }