提交 3e62cbb8 编写于 作者: D Dan Carpenter 提交者: James Morris

smack: opt_dentry is never null in in smack_d_instantiate()

This patch removes some unneeded code for if opt_dentry is null because
that can never happen.

The function dereferences "opt_dentry" earlier when it checks
"if (opt_dentry->d_parent == opt_dentry) {".  That code was added in
2008.

This function called from security_d_instantiate().  I checked all the
places which call security_d_instantiate() and dentry is always non-null.
I also checked the selinux version of this hook and there is a comment
which says that dentry should be non-null if called from
d_instantiate().
Signed-off-by: NDan Carpenter <error27@gmail.com>
Acked-by: NCasey Schaufler <casey@schaufler-ca.com>
Signed-off-by: NJames Morris <jmorris@namei.org>
上级 c3ef1500
...@@ -2191,7 +2191,7 @@ static void smack_ipc_getsecid(struct kern_ipc_perm *ipp, u32 *secid) ...@@ -2191,7 +2191,7 @@ static void smack_ipc_getsecid(struct kern_ipc_perm *ipp, u32 *secid)
/** /**
* smack_d_instantiate - Make sure the blob is correct on an inode * smack_d_instantiate - Make sure the blob is correct on an inode
* @opt_dentry: unused * @opt_dentry: dentry where inode will be attached
* @inode: the object * @inode: the object
* *
* Set the inode's security blob if it hasn't been done already. * Set the inode's security blob if it hasn't been done already.
...@@ -2310,20 +2310,10 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode) ...@@ -2310,20 +2310,10 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode)
/* /*
* Get the dentry for xattr. * Get the dentry for xattr.
*/ */
if (opt_dentry == NULL) { dp = dget(opt_dentry);
dp = d_find_alias(inode);
if (dp == NULL)
break;
} else {
dp = dget(opt_dentry);
if (dp == NULL)
break;
}
fetched = smk_fetch(inode, dp); fetched = smk_fetch(inode, dp);
if (fetched != NULL) if (fetched != NULL)
final = fetched; final = fetched;
dput(dp); dput(dp);
break; break;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册