[PATCH v2 07/14] fs/namei.c: lookup_open(): move i_op->create check before try_break_deleg()

From: Jori Koolstra

Date: Mon Jun 29 2026 - 11:53:22 EST


The i_op->create check in lookup_open() takes place after the
try_break_deleg() call. This does not match the order when doing a
regular file create via mknod(2). There the call order is:

filename_mknodat()
vfs_create()
i_op->create check
try_break_deleg()

Move the i_op->create check to before try_break_deleg() in
lookup_open().

Signed-off-by: Jori Koolstra <jkoolstra@xxxxxxxxx>
---
fs/namei.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index a7e179366703..063d40d5753e 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4546,15 +4546,15 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
goto out_dput;
}

- error = try_break_deleg(dir_inode, LEASE_BREAK_DIR_CREATE, delegated_inode);
- if (error)
- goto out_dput;
-
if (!dir_inode->i_op->create) {
error = -EACCES;
goto out_dput;
}

+ error = try_break_deleg(dir_inode, LEASE_BREAK_DIR_CREATE, delegated_inode);
+ if (error)
+ goto out_dput;
+
error = dir_inode->i_op->create(idmap, dir_inode, dentry,
mode, open_flag & O_EXCL);
if (error)
--
2.54.0