Skip to content

Commit c556690

Browse files
committed
udf: Skip parent dir link count update if corrupted
If the parent directory link count is too low (likely directory inode corruption), just skip updating its link count as if it goes to 0 too early it can cause unexpected issues. Signed-off-by: Jan Kara <[email protected]>
1 parent ac6f420 commit c556690

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/udf/namei.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,11 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
517517
inode->i_nlink);
518518
clear_nlink(inode);
519519
inode->i_size = 0;
520-
inode_dec_link_count(dir);
520+
if (dir->i_nlink >= 3)
521+
inode_dec_link_count(dir);
522+
else
523+
udf_warn(inode->i_sb, "parent dir link count too low (%u)\n",
524+
dir->i_nlink);
521525
udf_add_fid_counter(dir->i_sb, true, -1);
522526
inode_set_mtime_to_ts(dir,
523527
inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode)));

0 commit comments

Comments
 (0)