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
This commit is contained in:
Alexander Motin 2012-02-01 20:12:44 +00:00
parent 67b6f45325
commit 8f12d83ad9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=230877

View File

@ -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);
}