Commit 4770d96a authored by Christian Brauner's avatar Christian Brauner

fs: pull up trailing slashes check for O_CREAT

Perform the check for trailing slashes right in the fastpath check and
don't bother with any additional work.
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent c65d41c5
...@@ -3618,6 +3618,9 @@ static struct dentry *lookup_fast_for_open(struct nameidata *nd, int open_flag) ...@@ -3618,6 +3618,9 @@ static struct dentry *lookup_fast_for_open(struct nameidata *nd, int open_flag)
struct dentry *dentry; struct dentry *dentry;
if (open_flag & O_CREAT) { if (open_flag & O_CREAT) {
if (trailing_slashes(nd))
return ERR_PTR(-EISDIR);
/* Don't bother on an O_EXCL create */ /* Don't bother on an O_EXCL create */
if (open_flag & O_EXCL) if (open_flag & O_EXCL)
return NULL; return NULL;
...@@ -3684,20 +3687,13 @@ static const char *open_last_lookups(struct nameidata *nd, ...@@ -3684,20 +3687,13 @@ static const char *open_last_lookups(struct nameidata *nd,
bool unlazied; bool unlazied;
/* can stay in rcuwalk if not auditing */ /* can stay in rcuwalk if not auditing */
if (dentry && audit_dummy_context()) { if (dentry && audit_dummy_context())
if (trailing_slashes(nd))
return ERR_PTR(-EISDIR);
goto finish_lookup; goto finish_lookup;
}
unlazied = dentry ? try_to_unlazy_next(nd, dentry) : unlazied = dentry ? try_to_unlazy_next(nd, dentry) :
try_to_unlazy(nd); try_to_unlazy(nd);
if (!unlazied) if (!unlazied)
return ERR_PTR(-ECHILD); return ERR_PTR(-ECHILD);
} }
if (trailing_slashes(nd)) {
dput(dentry);
return ERR_PTR(-EISDIR);
}
if (dentry) if (dentry)
goto finish_lookup; goto finish_lookup;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment