From owner-svn-src-all@freebsd.org Sun Feb 5 14:03:27 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 40CEDCD2365; Sun, 5 Feb 2017 14:03:27 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1056DA51; Sun, 5 Feb 2017 14:03:26 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v15E3QVU001258; Sun, 5 Feb 2017 14:03:26 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v15E3QwK001257; Sun, 5 Feb 2017 14:03:26 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201702051403.v15E3QwK001257@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 5 Feb 2017 14:03:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r313283 - head/sys/compat/linux X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Feb 2017 14:03:27 -0000 Author: trasz Date: Sun Feb 5 14:03:25 2017 New Revision: 313283 URL: https://svnweb.freebsd.org/changeset/base/313283 Log: Fix linux_pipe() and linux_pipe2() to close file descriptors on copyout error. Reviewed by: dchagin MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D9425 Modified: head/sys/compat/linux/linux_file.c Modified: head/sys/compat/linux/linux_file.c ============================================================================== --- head/sys/compat/linux/linux_file.c Sun Feb 5 13:37:23 2017 (r313282) +++ head/sys/compat/linux/linux_file.c Sun Feb 5 14:03:25 2017 (r313283) @@ -1537,11 +1537,16 @@ linux_pipe(struct thread *td, struct lin #endif error = kern_pipe(td, fildes, 0, NULL, NULL); - if (error) + if (error != 0) return (error); - /* XXX: Close descriptors on error. */ - return (copyout(fildes, args->pipefds, sizeof(fildes))); + error = copyout(fildes, args->pipefds, sizeof(fildes)); + if (error != 0) { + (void)kern_close(td, fildes[0]); + (void)kern_close(td, fildes[1]); + } + + return (error); } int @@ -1564,11 +1569,16 @@ linux_pipe2(struct thread *td, struct li if ((args->flags & LINUX_O_CLOEXEC) != 0) flags |= O_CLOEXEC; error = kern_pipe(td, fildes, flags, NULL, NULL); - if (error) + if (error != 0) return (error); - /* XXX: Close descriptors on error. */ - return (copyout(fildes, args->pipefds, sizeof(fildes))); + error = copyout(fildes, args->pipefds, sizeof(fildes)); + if (error != 0) { + (void)kern_close(td, fildes[0]); + (void)kern_close(td, fildes[1]); + } + + return (error); } int