From 08bb34a547e99dad6c3b71ddd93d671e211b7f8a Mon Sep 17 00:00:00 2001 From: cem Date: Mon, 13 Jul 2015 17:45:22 +0000 Subject: [PATCH] pipe_direct_write: Fix mismatched pipelock/unlock If a signal is caught in pipelock, causing it to fail, pipe_direct_write should not try to pipeunlock. Reported by: pho Differential Revision: https://reviews.freebsd.org/D3069 Reviewed by: kib Approved by: markj (mentor) MFC after: 1 week Sponsored by: EMC / Isilon Storage Division --- sys/kern/sys_pipe.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 06a4d5acc4f4..70e76ad39952 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -946,9 +946,10 @@ pipe_direct_write(wpipe, uio) retry: PIPE_LOCK_ASSERT(wpipe, MA_OWNED); error = pipelock(wpipe, 1); - if (wpipe->pipe_state & PIPE_EOF) + if (error != 0) + goto error1; + if ((wpipe->pipe_state & PIPE_EOF) != 0) { error = EPIPE; - if (error) { pipeunlock(wpipe); goto error1; }