From owner-svn-src-all@FreeBSD.ORG Thu Dec 1 11:36:41 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 B8491106564A; Thu, 1 Dec 2011 11:36:41 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A78568FC13; Thu, 1 Dec 2011 11:36:41 +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 pB1Baf3U043249; Thu, 1 Dec 2011 11:36:41 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pB1BafvW043247; Thu, 1 Dec 2011 11:36:41 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201112011136.pB1BafvW043247@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 1 Dec 2011 11:36:41 +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: r228178 - 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, 01 Dec 2011 11:36:41 -0000 Author: kib Date: Thu Dec 1 11:36:41 2011 New Revision: 228178 URL: http://svn.freebsd.org/changeset/base/228178 Log: If alloc_unr() call in the pipe_create() failed, then pipe->pipe_ino is -1. But, because ino_t is unsigned, this case was not covered by the test ino > 0 in pipeclose(), leading to the free_unr(-1). Fix it by explicitely comparing with 0 and -1. [1] Do no access freed memory, the inode number was cached to prevent access to cpipe after it possibly was freed, but I failed to commit the right patch. Noted by: gianni [1] Pointy hat to: kib MFC after: 3 days Modified: head/sys/kern/sys_pipe.c Modified: head/sys/kern/sys_pipe.c ============================================================================== --- head/sys/kern/sys_pipe.c Thu Dec 1 11:20:25 2011 (r228177) +++ head/sys/kern/sys_pipe.c Thu Dec 1 11:36:41 2011 (r228178) @@ -1554,8 +1554,8 @@ pipeclose(cpipe) } else PIPE_UNLOCK(cpipe); - if (ino > 0) - free_unr(pipeino_unr, cpipe->pipe_ino); + if (ino != 0 && ino != (ino_t)-1) + free_unr(pipeino_unr, ino); } /*ARGSUSED*/