summaryrefslogtreecommitdiff
path: root/sys/dev/md/md.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/md/md.c')
-rw-r--r--sys/dev/md/md.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c
index 79c9587aeb43..3f03be4f424f 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);