When the SYSINIT() was removed, it was replaced with a make_dev on-demand

creation of /dev/drum via calling swapon. However, the make_dev has a
bogus (insofar that it hasn't been added yet) cdevsw, so later we end
up crashing with a null pointer dereference on the swap vp's specinfo.
The specinfo points to a dev_t with a major of 254 (uninitialized), and
we get a crash on its d_strategy being called.

The simple solution to this is to call cdevsw_add before the make_dev
is ever used. This fixes the panic which occurred upon swapping.
This commit is contained in:
Brian Feldman 1999-08-24 05:58:35 +00:00
parent 2832e35612
commit 076dab2983

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)vm_swap.c 8.5 (Berkeley) 2/17/94
* $Id: vm_swap.c,v 1.81 1999/08/13 10:29:38 phk Exp $
* $Id: vm_swap.c,v 1.82 1999/08/23 20:59:21 phk Exp $
*/
#include "opt_swap.h"
@ -205,6 +205,7 @@ swapon(p, uap)
static int once;
if (!once) {
cdevsw_add(&sw_cdevsw);
make_dev(&sw_cdevsw, 0, UID_ROOT, GID_KMEM, 0640, "drum");
once++;
}