-/* $OpenBSD: vfs_syscalls.c,v 1.348 2020/10/02 15:45:22 deraadt Exp $ */
+/* $OpenBSD: vfs_syscalls.c,v 1.349 2021/02/11 12:08:21 claudio Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
/*
cloexec = (oflags & O_CLOEXEC) ? UF_EXCLOSE : 0;
fdplock(fdp);
- if ((error = falloc(p, &fp, &indx)) != 0)
- goto out;
+ if ((error = falloc(p, &fp, &indx)) != 0) {
+ fdpunlock(fdp);
+ return (error);
+ }
fdpunlock(fdp);
flags = FFLAGS(oflags);
p->p_dupfd >= 0 && /* XXX from fdopen */
(error =
dupfdopen(p, indx, flags)) == 0) {
+ fdpunlock(fdp);
closef(fp, p);
*retval = indx;
- goto out;
+ return (error);
}
if (error == ERESTART)
error = EINTR;
fdremove(fdp, indx);
+ fdpunlock(fdp);
closef(fp, p);
- goto out;
+ return (error);
}
p->p_dupfd = 0;
vp = nd.ni_vp;
fdplock(fdp);
/* closef will vn_close the file for us. */
fdremove(fdp, indx);
+ fdpunlock(fdp);
closef(fp, p);
- goto out;
+ return (error);
}
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
atomic_setbits_int(&fp->f_iflags, FIF_HASLOCK);
fdplock(fdp);
/* closef will close the file for us. */
fdremove(fdp, indx);
+ fdpunlock(fdp);
closef(fp, p);
- goto out;
+ return (error);
}
}
VOP_UNLOCK(vp);
*retval = indx;
fdplock(fdp);
fdinsert(fdp, indx, cloexec, fp);
- FRELE(fp, p);
-out:
fdpunlock(fdp);
+ FRELE(fp, p);
return (error);
}
cloexec = (oflags & O_CLOEXEC) ? UF_EXCLOSE : 0;
fdplock(fdp);
- if ((error = falloc(p, &fp, &indx)) != 0)
- goto out;
+ if ((error = falloc(p, &fp, &indx)) != 0) {
+ fdpunlock(fdp);
+ return (error);
+ }
fdpunlock(fdp);
flags = FFLAGS(oflags);
cmode = 0600;
NDINITAT(&nd, 0, KERNELPATH, UIO_SYSSPACE, AT_FDCWD, path, p);
if ((error = vn_open(&nd, flags, cmode)) != 0) {
- fdplock(fdp);
if (error == ERESTART)
error = EINTR;
+ fdplock(fdp);
fdremove(fdp, indx);
+ fdpunlock(fdp);
closef(fp, p);
- goto out;
+ return (error);
}
vp = nd.ni_vp;
fp->f_flag = flags & FMASK;
*retval = indx;
fdplock(fdp);
fdinsert(fdp, indx, cloexec, fp);
+ fdpunlock(fdp);
FRELE(fp, p);
/* unlink it */
}
}
-out:
- fdpunlock(fdp);
return (error);
}
fdplock(fdp);
if ((error = falloc(p, &fp, &indx)) != 0) {
+ fdpunlock(fdp);
fp = NULL;
goto bad;
}
+ fdpunlock(fdp);
if ((error = copyin(SCARG(uap, fhp), &fh, sizeof(fhandle_t))) != 0)
goto bad;
}
VOP_UNLOCK(vp);
*retval = indx;
+ fdplock(fdp);
fdinsert(fdp, indx, cloexec, fp);
fdpunlock(fdp);
FRELE(fp, p);
bad:
if (fp) {
+ fdplock(fdp);
fdremove(fdp, indx);
+ fdpunlock(fdp);
closef(fp, p);
if (vp != NULL)
vput(vp);
}
- fdpunlock(fdp);
return (error);
}