Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ext2: avoid drop_nlink() during unlink of zero-nlink inode in ext2_unlink()

ext2_unlink() calls inode_dec_link_count() unconditionally, which
invokes drop_nlink(). If the inode was loaded from a corrupted disk
image with i_links_count == 0, drop_nlink()
triggers WARN_ON(inode->i_nlink == 0)

Follow the ext4 pattern from __ext4_unlink(): check i_nlink before
decrementing. If already zero, skip the decrement.

Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
Link: https://patch.msgid.link/20260211022052.973114-1-n7l8m4@u.northwestern.edu
Signed-off-by: Jan Kara <jack@suse.cz>

authored by

Ziyi Guo and committed by
Jan Kara
19134a13 ad0e9663

+4 -1
+4 -1
fs/ext2/namei.c
··· 291 291 goto out; 292 292 293 293 inode_set_ctime_to_ts(inode, inode_get_ctime(dir)); 294 - inode_dec_link_count(inode); 294 + 295 + if (inode->i_nlink) 296 + inode_dec_link_count(inode); 297 + 295 298 err = 0; 296 299 out: 297 300 return err;