diff options
author | Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> | 2013-07-24 16:44:02 -0400 |
---|---|---|
committer | James Morris <james.l.morris@oracle.com> | 2013-07-25 05:30:03 -0400 |
commit | 9548906b2bb7ff09e12c013a55d669bef2c8e121 (patch) | |
tree | b75ba2bc69d82c1040cac0ea9113a17b39e82b93 /security/selinux/hooks.c | |
parent | be0306bcc3a0b0725b0f99b06d56a29a6d906b7c (diff) |
xattr: Constify ->name member of "struct xattr".
Since everybody sets kstrdup()ed constant string to "struct xattr"->name but
nobody modifies "struct xattr"->name , we can omit kstrdup() and its failure
checking by constifying ->name member of "struct xattr".
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reviewed-by: Joel Becker <jlbec@evilplan.org> [ocfs2]
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Acked-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Reviewed-by: Paul Moore <paul@paul-moore.com>
Tested-by: Paul Moore <paul@paul-moore.com>
Acked-by: Eric Paris <eparis@redhat.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r-- | security/selinux/hooks.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index c956390a9136..a5091ec06aa6 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -2587,7 +2587,8 @@ static int selinux_dentry_init_security(struct dentry *dentry, int mode, | |||
2587 | } | 2587 | } |
2588 | 2588 | ||
2589 | static int selinux_inode_init_security(struct inode *inode, struct inode *dir, | 2589 | static int selinux_inode_init_security(struct inode *inode, struct inode *dir, |
2590 | const struct qstr *qstr, char **name, | 2590 | const struct qstr *qstr, |
2591 | const char **name, | ||
2591 | void **value, size_t *len) | 2592 | void **value, size_t *len) |
2592 | { | 2593 | { |
2593 | const struct task_security_struct *tsec = current_security(); | 2594 | const struct task_security_struct *tsec = current_security(); |
@@ -2595,7 +2596,7 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir, | |||
2595 | struct superblock_security_struct *sbsec; | 2596 | struct superblock_security_struct *sbsec; |
2596 | u32 sid, newsid, clen; | 2597 | u32 sid, newsid, clen; |
2597 | int rc; | 2598 | int rc; |
2598 | char *namep = NULL, *context; | 2599 | char *context; |
2599 | 2600 | ||
2600 | dsec = dir->i_security; | 2601 | dsec = dir->i_security; |
2601 | sbsec = dir->i_sb->s_security; | 2602 | sbsec = dir->i_sb->s_security; |
@@ -2631,19 +2632,13 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir, | |||
2631 | if (!ss_initialized || !(sbsec->flags & SE_SBLABELSUPP)) | 2632 | if (!ss_initialized || !(sbsec->flags & SE_SBLABELSUPP)) |
2632 | return -EOPNOTSUPP; | 2633 | return -EOPNOTSUPP; |
2633 | 2634 | ||
2634 | if (name) { | 2635 | if (name) |
2635 | namep = kstrdup(XATTR_SELINUX_SUFFIX, GFP_NOFS); | 2636 | *name = XATTR_SELINUX_SUFFIX; |
2636 | if (!namep) | ||
2637 | return -ENOMEM; | ||
2638 | *name = namep; | ||
2639 | } | ||
2640 | 2637 | ||
2641 | if (value && len) { | 2638 | if (value && len) { |
2642 | rc = security_sid_to_context_force(newsid, &context, &clen); | 2639 | rc = security_sid_to_context_force(newsid, &context, &clen); |
2643 | if (rc) { | 2640 | if (rc) |
2644 | kfree(namep); | ||
2645 | return rc; | 2641 | return rc; |
2646 | } | ||
2647 | *value = context; | 2642 | *value = context; |
2648 | *len = clen; | 2643 | *len = clen; |
2649 | } | 2644 | } |