From 3d3c27fedfef320e6fe72465586e342daae803af Mon Sep 17 00:00:00 2001 From: Thomas Moestl Date: Thu, 26 Jul 2001 20:05:20 +0000 Subject: 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 --- sys/dev/md/md.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sys/dev') diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 79c9587aeb43f..3f03be4f424f7 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); -- cgit v1.3