From owner-svn-src-all@freebsd.org Thu Jan 7 21:43:44 2016 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 980BAA67E52; Thu, 7 Jan 2016 21:43:44 +0000 (UTC) (envelope-from pfg@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 65E991788; Thu, 7 Jan 2016 21:43:44 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u07Lhh7V057998; Thu, 7 Jan 2016 21:43:43 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u07LhhVo057997; Thu, 7 Jan 2016 21:43:43 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201601072143.u07LhhVo057997@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Thu, 7 Jan 2016 21:43:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r293370 - head/sys/fs/ext2fs 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.20 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, 07 Jan 2016 21:43:44 -0000 Author: pfg Date: Thu Jan 7 21:43:43 2016 New Revision: 293370 URL: https://svnweb.freebsd.org/changeset/base/293370 Log: ext2fs: reading mmaped file in Ext4 causes panic Always call brelse(path.ep_bp), fixing reading EXT4 files using mmap(). Patch by Damjan Jovanovic. PR: 205938 MFC after: 1 week Modified: head/sys/fs/ext2fs/ext2_bmap.c Modified: head/sys/fs/ext2fs/ext2_bmap.c ============================================================================== --- head/sys/fs/ext2fs/ext2_bmap.c Thu Jan 7 21:16:44 2016 (r293369) +++ head/sys/fs/ext2fs/ext2_bmap.c Thu Jan 7 21:43:43 2016 (r293370) @@ -96,6 +96,7 @@ ext4_bmapext(struct vnode *vp, int32_t b struct ext4_extent *ep; struct ext4_extent_path path = { .ep_bp = NULL }; daddr_t lbn; + int ret = 0; ip = VTOI(vp); fs = ip->i_e2fs; @@ -113,15 +114,21 @@ ext4_bmapext(struct vnode *vp, int32_t b ext4_ext_find_extent(fs, ip, lbn, &path); ep = path.ep_ext; if (ep == NULL) - return (EIO); + ret = EIO; + else { + *bnp = fsbtodb(fs, lbn - ep->e_blk + + (ep->e_start_lo | (daddr_t)ep->e_start_hi << 32)); - *bnp = fsbtodb(fs, lbn - ep->e_blk + - (ep->e_start_lo | (daddr_t)ep->e_start_hi << 32)); + if (*bnp == 0) + *bnp = -1; + } - if (*bnp == 0) - *bnp = -1; + if (path.ep_bp != NULL) { + brelse(path.ep_bp); + path.ep_bp = NULL; + } - return (0); + return (ret); } /*