[PATCH 2/2] nilfs: check new inode's nlink when rename
Wang Jianjian <[email protected]> Thu, 30 Jul 2026 20:01:05 +0800
| Newsgroups | org.kernel.vger.linux-nilfs |
|---|---|
| Message-ID | <[email protected]> |
When rename, if new inode exists, then its nlink must not be zero. Signed-off-by: Wang Jianjian <[email protected]> --- fs/nilfs2/namei.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c index e2fe95de3d71..db171789a316 100644 --- a/fs/nilfs2/namei.c +++ b/fs/nilfs2/namei.c @@ -397,6 +397,11 @@ static int nilfs_rename(struct mnt_idmap *idmap, struct folio *new_folio; struct nilfs_dir_entry *new_de; + if (new_inode->i_nlink == 0) { + err = -EFSCORRUPTED; + goto out_dir; + } + err = -ENOTEMPTY; if (old_is_dir && !nilfs_empty_dir(new_inode)) goto out_dir; -- 2.34.1