summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-01-10 22:30:39 +0000
committerpfg <pfg@FreeBSD.org>2016-01-10 22:30:39 +0000
commitd10ff89a31425b9a2c8478ba1f7a305136b260b1 (patch)
treed2077f65edcdc74f4f24cefcff2c4db8543d3eef /sys
parente491a7871f29b017f7fe0432fc303bd6ff5dd6e0 (diff)
downloadFreeBSD-src-d10ff89a31425b9a2c8478ba1f7a305136b260b1.zip
FreeBSD-src-d10ff89a31425b9a2c8478ba1f7a305136b260b1.tar.gz
MFC r293370:
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
Diffstat (limited to 'sys')
-rw-r--r--sys/fs/ext2fs/ext2_bmap.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/sys/fs/ext2fs/ext2_bmap.c b/sys/fs/ext2fs/ext2_bmap.c
index d144e92..7d4a880 100644
--- a/sys/fs/ext2fs/ext2_bmap.c
+++ b/sys/fs/ext2fs/ext2_bmap.c
@@ -96,6 +96,7 @@ ext4_bmapext(struct vnode *vp, int32_t bn, int64_t *bnp, int *runp, int *runb)
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 bn, int64_t *bnp, int *runp, int *runb)
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);
}
/*
OpenPOWER on IntegriCloud