summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorMike Belopuhov <mikeb@cvs.openbsd.org>2012-05-06 09:45:27 +0000
committerMike Belopuhov <mikeb@cvs.openbsd.org>2012-05-06 09:45:27 +0000
commit06d619978dcb68cc10809dc4cec019c7fb2488e0 (patch)
treeda82bd5b3e5232969a568513a6d0362f7aa815ca /sys/kern
parent56bb9710e27053b6536f581dbdaab4b6cf6c392e (diff)
take a file descriptor table lock after allocating pipe structures
and buffers; ok guenther
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/sys_pipe.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 5e0058013c0..20cb0bbcb3c 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_pipe.c,v 1.62 2012/04/22 05:43:14 guenther Exp $ */
+/* $OpenBSD: sys_pipe.c,v 1.63 2012/05/06 09:45:26 mikeb Exp $ */
/*
* Copyright (c) 1996 John S. Dyson
@@ -108,11 +108,9 @@ sys_pipe(struct proc *p, void *v, register_t *retval)
} */ *uap = v;
struct filedesc *fdp = p->p_fd;
struct file *rf, *wf;
- struct pipe *rpipe, *wpipe;
+ struct pipe *rpipe, *wpipe = NULL;
int fds[2], error;
- fdplock(fdp);
-
rpipe = pool_get(&pipe_pool, PR_WAITOK);
error = pipe_create(rpipe);
if (error != 0)
@@ -120,7 +118,9 @@ sys_pipe(struct proc *p, void *v, register_t *retval)
wpipe = pool_get(&pipe_pool, PR_WAITOK);
error = pipe_create(wpipe);
if (error != 0)
- goto free2;
+ goto free1;
+
+ fdplock(fdp);
error = falloc(p, &rf, &fds[0]);
if (error != 0)
@@ -157,11 +157,10 @@ free3:
closef(rf, p);
rpipe = NULL;
free2:
- (void)pipeclose(wpipe);
-free1:
- if (rpipe != NULL)
- (void)pipeclose(rpipe);
fdpunlock(fdp);
+free1:
+ pipeclose(wpipe);
+ pipeclose(rpipe);
return (error);
}