f2fs: fix error handling on device alias check in rename and unlink

In f2fs_rename() and f2fs_unlink(), directly returning -EPERM when
encountering a device aliasing file bypasses the cleanup path.

Fix this by setting err to -EPERM and jumping to the proper cleanup
labels (out_dir and out) instead of returning immediately.

Reported-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Daeho Jeong
2026-08-21 07:17:42 -07:00
committed by Jaegeuk Kim
parent 2b8704b6a8
commit 11d56d7a8e

View File

@@ -571,8 +571,10 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
trace_f2fs_unlink_enter(dir, dentry);
if (IS_DEVICE_ALIASING(inode))
return -EPERM;
if (IS_DEVICE_ALIASING(inode)) {
err = -EPERM;
goto out;
}
if (unlikely(f2fs_cp_error(sbi))) {
err = -EIO;
@@ -1025,8 +1027,10 @@ static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
}
if (new_inode) {
if (IS_DEVICE_ALIASING(new_inode))
return -EPERM;
if (IS_DEVICE_ALIASING(new_inode)) {
err = -EPERM;
goto out_dir;
}
err = -ENOTEMPTY;
if (old_is_dir && !f2fs_empty_dir(new_inode))