diff options
author | Markus Elfring <elfring@users.sourceforge.net> | 2017-04-04 11:33:53 +0200 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2017-05-23 10:23:17 -0400 |
commit | 46be14d2b6fbc20c9e7008ec8c28b40609ef6f22 (patch) | |
tree | 352a3b73065c2e39802068d2b38f3a6d25177533 /security/selinux | |
parent | 62934ffb9e5f9a904c83f571590631b766d68d12 (diff) | |
download | linux-stable-46be14d2b6fbc20c9e7008ec8c28b40609ef6f22.tar.gz linux-stable-46be14d2b6fbc20c9e7008ec8c28b40609ef6f22.tar.bz2 linux-stable-46be14d2b6fbc20c9e7008ec8c28b40609ef6f22.zip |
selinux: Return an error code only as a constant in sidtab_insert()
* Return an error code without storing it in an intermediate variable.
* Delete the local variable "rc" and the jump label "out" which became
unnecessary with this refactoring.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security/selinux')
-rw-r--r-- | security/selinux/ss/sidtab.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c index f6915f257486..c5f436b15d19 100644 --- a/security/selinux/ss/sidtab.c +++ b/security/selinux/ss/sidtab.c @@ -32,13 +32,11 @@ int sidtab_init(struct sidtab *s) int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) { - int hvalue, rc = 0; + int hvalue; struct sidtab_node *prev, *cur, *newnode; - if (!s) { - rc = -ENOMEM; - goto out; - } + if (!s) + return -ENOMEM; hvalue = SIDTAB_HASH(sid); prev = NULL; @@ -48,21 +46,17 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) cur = cur->next; } - if (cur && sid == cur->sid) { - rc = -EEXIST; - goto out; - } + if (cur && sid == cur->sid) + return -EEXIST; newnode = kmalloc(sizeof(*newnode), GFP_ATOMIC); - if (!newnode) { - rc = -ENOMEM; - goto out; - } + if (!newnode) + return -ENOMEM; + newnode->sid = sid; if (context_cpy(&newnode->context, context)) { kfree(newnode); - rc = -ENOMEM; - goto out; + return -ENOMEM; } if (prev) { @@ -78,8 +72,7 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) s->nel++; if (sid >= s->next_sid) s->next_sid = sid + 1; -out: - return rc; + return 0; } static struct context *sidtab_search_core(struct sidtab *s, u32 sid, int force) |