Skip to contentSkip to conversation

f2fs: fix a problem of using memory after free

PATCH Superseded Yunlei He 2 participants 2 messages Dec 19, 2016 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH 1/1 f2fs: fix a problem of using memory after free

This patch fix a problem of using memory after free in the function __try_merge_extent_node.

Fixes a03f01f2673 ("f2fs: reconstruct the code to free an extent_node")
---
 fs/f2fs/extent_cache.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/extent_cache.c +3 -2
index 4db44da..e02c3d8 100644
@@ -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;
 	}
 
Signature · 6 lines
2.10.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Reviewed-by on v1 1/1
#1 lore raw

Hi Yunlei,

Please correct wrong Cced email address of stable mailing list:
[email protected] -> [email protected]

Quoted 4 lines · Yunlei He

This patch fix a problem of using memory after free in the function __try_merge_extent_node.

Fixes a03f01f2673 ("f2fs: reconstruct the code to free an extent_node")
Fixes 0f825ee6e873 ("f2fs: add new interfaces for extent tree")
Quoted 1 line
Quoted 14 lines
---
 fs/f2fs/extent_cache.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/extent_cache.c +0 -1
index 4db44da..e02c3d8 100644
@@ -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)

fs/f2fs/extent_cache.c static struct extent_node *__try_merge_extent_node(struct inode *inode, · line 363

Quoted 10 lines
fs/f2fs/extent_cache.c +3 -1
-			__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;
 	}
 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot