there's no apparent need to take a file descriptor table lock
before we've done allocating pipe structures and buffers. ok?

Index: sys/kern/sys_pipe.c
===================================================================
RCS file: /home/cvs/src/sys/kern/sys_pipe.c,v
retrieving revision 1.61
diff -u -p -r1.61 sys_pipe.c
--- sys/kern/sys_pipe.c 8 Jul 2011 19:00:09 -0000       1.61
+++ sys/kern/sys_pipe.c 11 Apr 2012 18:44:23 -0000
@@ -108,11 +108,9 @@ sys_pipe(struct proc *p, void *v, regist
        } */ *uap = v;
        struct filedesc *fdp = p->p_fd;
        struct file *rf, *wf;
-       struct pipe *rpipe, *wpipe;
+       struct pipe *rpipe = NULL, *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, regist
        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,12 @@ free3:
        closef(rf, p);
        rpipe = NULL;
 free2:
-       (void)pipeclose(wpipe);
+       fdpunlock(fdp);
 free1:
+       if (wpipe != NULL)
+               (void)pipeclose(wpipe);
        if (rpipe != NULL)
                (void)pipeclose(rpipe);
-       fdpunlock(fdp);
        return (error);
 }

Reply via email to