diff options
author | tmm <tmm@FreeBSD.org> | 2001-07-26 20:05:20 +0000 |
---|---|---|
committer | tmm <tmm@FreeBSD.org> | 2001-07-26 20:05:20 +0000 |
commit | 6ba9978f5d17181b365af2302ddbdc9b563da2cf (patch) | |
tree | ef646ad7e3c4247be08bca5555bb5b04c4b2fb43 /sys | |
parent | d106b78011ceca12159f46d0be07e2d54237c469 (diff) | |
download | FreeBSD-src-6ba9978f5d17181b365af2302ddbdc9b563da2cf.zip FreeBSD-src-6ba9978f5d17181b365af2302ddbdc9b563da2cf.tar.gz |
Make sure the total number of sectors is not 0 for a vnode-type md to
avoid a division by zero which would occur on open() in this case.
Reviewed by: phk
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/md/md.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 79c9587..3f03be4 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -678,6 +678,10 @@ mdcreate_vnode(struct md_ioctl *mdio, struct proc *p) sc->nsect = mdio->md_size; else sc->nsect = vattr.va_size / sc->secsize; /* XXX: round up ? */ + if (sc->nsect == 0) { + (void) vn_close(nd.ni_vp, flags, p->p_ucred, p); + return (EINVAL); + } error = mdsetcred(sc, p->p_ucred); if (error) { (void) vn_close(nd.ni_vp, flags, p->p_ucred, p); |