diff options
author | bde <bde@FreeBSD.org> | 1998-10-25 16:11:49 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1998-10-25 16:11:49 +0000 |
commit | b17bde009a29901e8647e3d0c680a716f3526a2d (patch) | |
tree | 551e0a0b6fba4052dbf4f0b00ad5a838e06115a9 /sys/kern | |
parent | 0230a7360f37e005e358fcbb4b08e645428b442d (diff) | |
download | FreeBSD-src-b17bde009a29901e8647e3d0c680a716f3526a2d.zip FreeBSD-src-b17bde009a29901e8647e3d0c680a716f3526a2d.tar.gz |
Fixed device number checking in bdevvp():
- dev != NODEV was checked for, but 0 was returned on failure. This was
fixed in Lite2 (except the return code was still slightly wrong (ENODEV
instead of ENXIO)) but the changes were not merged. This case probably
doesn't actually occur under FreeBSD.
- major(dev) was not checked to have a valid non-NULL bdevsw entry. This
caused panics when the driver for the root device didn't exist.
Fixed minor misformattings in bdevvp(). Rev.1.14 consisted mainly of
gratuitous reformattings that seem to have caused many Lite2 merge
errors.
PR: 8417
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/vfs_export.c | 16 | ||||
-rw-r--r-- | sys/kern/vfs_subr.c | 16 |
2 files changed, 20 insertions, 12 deletions
diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c index 867cf88..c0117a6 100644 --- a/sys/kern/vfs_export.c +++ b/sys/kern/vfs_export.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 - * $Id: vfs_subr.c,v 1.165 1998/10/13 08:24:41 dg Exp $ + * $Id: vfs_subr.c,v 1.166 1998/10/14 15:05:52 dt Exp $ */ /* @@ -46,6 +46,7 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/conf.h> #include <sys/kernel.h> #include <sys/proc.h> #include <sys/malloc.h> @@ -1126,16 +1127,19 @@ bdevvp(dev, vpp) struct vnode *nvp; int error; - if (dev == NODEV) - return (0); - error = getnewvnode(VT_NON, (struct mount *) 0, spec_vnodeop_p, &nvp); + if (dev == NODEV || major(dev) >= nblkdev || + bdevsw[major(dev)] == NULL) { + *vpp = NULLVP; + return (ENXIO); + } + error = getnewvnode(VT_NON, (struct mount *)0, spec_vnodeop_p, &nvp); if (error) { - *vpp = 0; + *vpp = NULLVP; return (error); } vp = nvp; vp->v_type = VBLK; - if ((nvp = checkalias(vp, dev, (struct mount *) 0))) { + if ((nvp = checkalias(vp, dev, (struct mount *)0)) != NULL) { vput(vp); vp = nvp; } diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 867cf88..c0117a6 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95 - * $Id: vfs_subr.c,v 1.165 1998/10/13 08:24:41 dg Exp $ + * $Id: vfs_subr.c,v 1.166 1998/10/14 15:05:52 dt Exp $ */ /* @@ -46,6 +46,7 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/conf.h> #include <sys/kernel.h> #include <sys/proc.h> #include <sys/malloc.h> @@ -1126,16 +1127,19 @@ bdevvp(dev, vpp) struct vnode *nvp; int error; - if (dev == NODEV) - return (0); - error = getnewvnode(VT_NON, (struct mount *) 0, spec_vnodeop_p, &nvp); + if (dev == NODEV || major(dev) >= nblkdev || + bdevsw[major(dev)] == NULL) { + *vpp = NULLVP; + return (ENXIO); + } + error = getnewvnode(VT_NON, (struct mount *)0, spec_vnodeop_p, &nvp); if (error) { - *vpp = 0; + *vpp = NULLVP; return (error); } vp = nvp; vp->v_type = VBLK; - if ((nvp = checkalias(vp, dev, (struct mount *) 0))) { + if ((nvp = checkalias(vp, dev, (struct mount *)0)) != NULL) { vput(vp); vp = nvp; } |