diff options
| author | Jan Kara <jack@suse.cz> | 2024-11-26 12:46:00 +0100 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-01-02 10:32:04 +0100 |
| commit | 3dea3c59c4bd3a6957b04e7332ad1df2ac6ca47a (patch) | |
| tree | 7bf65b1b6326daaa594f4bad12fd8f94972b09ce /fs/udf | |
| parent | f50783148ec98a1d38b87422e2ceaf2380b7b606 (diff) | |
| download | linux-3dea3c59c4bd3a6957b04e7332ad1df2ac6ca47a.tar.gz linux-3dea3c59c4bd3a6957b04e7332ad1df2ac6ca47a.tar.bz2 linux-3dea3c59c4bd3a6957b04e7332ad1df2ac6ca47a.zip | |
udf: Skip parent dir link count update if corrupted
[ Upstream commit c5566903af56dd1abb092f18dcb0c770d6cd8dcb ]
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 <jack@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/udf')
| -rw-r--r-- | fs/udf/namei.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 605f182da42c..b3f57ad2b869 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c @@ -521,7 +521,11 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry) inode->i_nlink); clear_nlink(inode); inode->i_size = 0; - inode_dec_link_count(dir); + if (dir->i_nlink >= 3) + inode_dec_link_count(dir); + else + udf_warn(inode->i_sb, "parent dir link count too low (%u)\n", + dir->i_nlink); udf_add_fid_counter(dir->i_sb, true, -1); dir->i_mtime = inode_set_ctime_to_ts(dir, inode_set_ctime_current(inode)); |
