diff options
author | bde <bde@FreeBSD.org> | 1998-10-25 19:24:04 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1998-10-25 19:24:04 +0000 |
commit | 9fafc4765300a0de262e82faff274b179b1c3772 (patch) | |
tree | ff81b7ad9a7d8056a3d910c0e50c4ba84df3aca3 /sys/vm/vm_swap.c | |
parent | 5a7ea1209a9c22e10c1ec8e2ee7563850f5f7648 (diff) | |
download | FreeBSD-src-9fafc4765300a0de262e82faff274b179b1c3772.zip FreeBSD-src-9fafc4765300a0de262e82faff274b179b1c3772.tar.gz |
Don't follow null bdevsw pointers. The `major(dev) < nblkdev' test rotted
when bdevsw[] became sparse. We still depend on magic to avoid having to
check that (v_rdev) device numbers in vnodes are not NODEV.
Removed a redundant `major(dev) < nblkdev' test instead of updating it.
Don't follow a garbage bdevsw pointer for attempts to swap on empty
regular files. This case currently can't happen. Swapping on regular
files is ifdefed out in swapon() and isn't attempted for empty files
in nfs_mountroot().
Diffstat (limited to 'sys/vm/vm_swap.c')
-rw-r--r-- | sys/vm/vm_swap.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/sys/vm/vm_swap.c b/sys/vm/vm_swap.c index 10488d9..bfcebdc 100644 --- a/sys/vm/vm_swap.c +++ b/sys/vm/vm_swap.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)vm_swap.c 8.5 (Berkeley) 2/17/94 - * $Id: vm_swap.c,v 1.55 1998/07/04 20:45:42 julian Exp $ + * $Id: vm_swap.c,v 1.56 1998/07/04 22:30:26 julian Exp $ */ #include "opt_devfs.h" @@ -203,8 +203,8 @@ swapon(p, uap) switch (vp->v_type) { case VBLK: - dev = (dev_t) vp->v_rdev; - if (major(dev) >= nblkdev) { + dev = vp->v_rdev; + if (major(dev) >= nblkdev || bdevsw[major(dev)] == NULL) { error = ENXIO; break; } @@ -264,14 +264,11 @@ swaponvp(p, vp, dev, nblks) } return EINVAL; found: - if (dev != NODEV && (major(dev) >= nblkdev)) - return (ENXIO); - error = VOP_OPEN(vp, FREAD | FWRITE, p->p_ucred, p); if (error) return (error); - if (nblks == 0 && (bdevsw[major(dev)]->d_psize == 0 || + if (nblks == 0 && dev != NODEV && (bdevsw[major(dev)]->d_psize == 0 || (nblks = (*bdevsw[major(dev)]->d_psize) (dev)) == -1)) { (void) VOP_CLOSE(vp, FREAD | FWRITE, p->p_ucred, p); return (ENXIO); |