Commit 6036c5f1 authored by Luís Henriques's avatar Luís Henriques Committed by Christian Brauner

fs: simplify misleading code to remove ambiguity regarding ihold()/iput()

Because 'inode' is being initialised before checking if 'dentry' is negative
it looks like an extra iput() on 'inode' may happen since the ihold() is
done only if the dentry is *not* negative.  In reality this doesn't happen
because d_is_negative() is never true if ->d_inode is NULL.  This patch only
makes the code easier to understand, as I was initially mislead by it.
Signed-off-by: default avatarLuís Henriques <lhenriques@suse.de>
Link: https://lore.kernel.org/r/20230928152341.303-1-lhenriques@suse.deSigned-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 85fadf89
......@@ -4367,11 +4367,9 @@ int do_unlinkat(int dfd, struct filename *name)
if (!IS_ERR(dentry)) {
/* Why not before? Because we want correct error value */
if (last.name[last.len])
if (last.name[last.len] || d_is_negative(dentry))
goto slashes;
inode = dentry->d_inode;
if (d_is_negative(dentry))
goto slashes;
ihold(inode);
error = security_path_unlink(&path, dentry);
if (error)
......
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