summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunlei He <heyunlei@huawei.com>2016-12-19 15:10:48 +0300
committerJaegeuk Kim <jaegeuk@kernel.org>2017-01-29 06:46:01 +0300
commit7855eba4d6102f811b6dd142d6c749f53b591fa3 (patch)
treefe3d4bd41eec36e334bacc074a134e10626db079
parent07fe8d44409f88be8f4a4e8f22b47ee709a22657 (diff)
downloadlinux-7855eba4d6102f811b6dd142d6c749f53b591fa3.tar.xz
f2fs: fix a problem of using memory after free
This patch fix a problem of using memory after free in function __try_merge_extent_node. Fixes: 0f825ee6e873 ("f2fs: add new interfaces for extent tree") Cc: <stable@vger.kernel.org> Signed-off-by: Yunlei He <heyunlei@huawei.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/extent_cache.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index 4db44da7ef69..e02c3d88dc9a 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -352,11 +352,12 @@ static struct extent_node *__try_merge_extent_node(struct inode *inode,
}
if (next_ex && __is_front_mergeable(ei, &next_ex->ei)) {
- if (en)
- __release_extent_node(sbi, et, prev_ex);
next_ex->ei.fofs = ei->fofs;
next_ex->ei.blk = ei->blk;
next_ex->ei.len += ei->len;
+ if (en)
+ __release_extent_node(sbi, et, prev_ex);
+
en = next_ex;
}