Skip to content

Commit ef6919c

Browse files
committed
ext2: Fix error handling on inode bitmap corruption
When insert_inode_locked() fails in ext2_new_inode() it most likely means inode bitmap got corrupted and we allocated again inode which is already in use. Also doing unlock_new_inode() during error recovery is wrong since the inode does not have I_NEW set. Fix the problem by informing about filesystem error and jumping to fail: (instead of fail_drop:) which doesn't call unlock_new_inode(). Reviewed-by: Eric Sandeen <[email protected]> Signed-off-by: Jan Kara <[email protected]>
1 parent 1415dd8 commit ef6919c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/ext2/ialloc.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,11 @@ struct inode *ext2_new_inode(struct inode *dir, int mode,
573573
inode->i_generation = sbi->s_next_generation++;
574574
spin_unlock(&sbi->s_next_gen_lock);
575575
if (insert_inode_locked(inode) < 0) {
576-
err = -EINVAL;
577-
goto fail_drop;
576+
ext2_error(sb, "ext2_new_inode",
577+
"inode number already in use - inode=%lu",
578+
(unsigned long) ino);
579+
err = -EIO;
580+
goto fail;
578581
}
579582

580583
dquot_initialize(inode);

0 commit comments

Comments
 (0)