Skip to contentSkip to conversation

f2fs: handle error from f2fs_iget_nowait

PATCH In review Namjae Jeon 1 participant 1 message Dec 22, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/5 f2fs: handle error from f2fs_iget_nowait

From: Namjae Jeon <[email protected]>

In case f2fs_iget_nowait returns error, it results in truncate_hole being called with 'error' value as inode pointer. There is no check in truncate_hole for valid inode, so it could result in crash due "invalid access to memory". Avoid this by handling error condition properly.

---
 fs/f2fs/recovery.c |    3 +++
 1 file changed, 3 insertions(+)
fs/f2fs/recovery.c +3 -0
index b07e9b6..632e679 100644
@@ -228,6 +228,9 @@ static void check_index_in_prev_nodes(struct f2fs_sb_info *sbi,
 
 	/* Deallocate previous index in the node page */
 	inode = f2fs_iget_nowait(sbi->sb, ino);
+	if (IS_ERR(inode))
+		return;
+
 	truncate_hole(inode, bidx, bidx + 1);
 	iput(inode);
 }
Signature · 1 line
1.7.9.5