From owner-svn-src-all@FreeBSD.ORG Thu Aug 11 13:30:00 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A4D41065673; Thu, 11 Aug 2011 13:30:00 +0000 (UTC) (envelope-from jonathan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0995C8FC14; Thu, 11 Aug 2011 13:30:00 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7BDTxxb094721; Thu, 11 Aug 2011 13:29:59 GMT (envelope-from jonathan@svn.freebsd.org) Received: (from jonathan@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7BDTxVN094719; Thu, 11 Aug 2011 13:29:59 GMT (envelope-from jonathan@svn.freebsd.org) Message-Id: <201108111329.p7BDTxVN094719@svn.freebsd.org> From: Jonathan Anderson Date: Thu, 11 Aug 2011 13:29:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224781 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Thu, 11 Aug 2011 13:30:00 -0000 Author: jonathan Date: Thu Aug 11 13:29:59 2011 New Revision: 224781 URL: http://svn.freebsd.org/changeset/base/224781 Log: Only call fdclose() on successfully-opened FDs. Since kern_openat() now uses falloc_noinstall() and finstall() separately, there are cases where we could get to cleanup code without ever creating a file descriptor. In those cases, we should not call fdclose() on FD -1. Approved by: re (kib), mentor (rwatson) Sponsored by: Google Inc Modified: head/sys/kern/vfs_syscalls.c Modified: head/sys/kern/vfs_syscalls.c ============================================================================== --- head/sys/kern/vfs_syscalls.c Thu Aug 11 13:15:11 2011 (r224780) +++ head/sys/kern/vfs_syscalls.c Thu Aug 11 13:29:59 2011 (r224781) @@ -1116,7 +1116,8 @@ kern_openat(struct thread *td, int fd, c * Clean up the descriptor, but only if another thread hadn't * replaced or closed it. */ - fdclose(fdp, fp, indx, td); + if (indx != -1) + fdclose(fdp, fp, indx, td); fdrop(fp, td); if (error == ERESTART) @@ -1185,7 +1186,8 @@ success: bad: VFS_UNLOCK_GIANT(vfslocked); bad_unlocked: - fdclose(fdp, fp, indx, td); + if (indx != -1) + fdclose(fdp, fp, indx, td); fdrop(fp, td); td->td_retval[0] = -1; return (error);