Commit 46be14d2 authored by Markus Elfring's avatar Markus Elfring Committed by Paul Moore

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: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
parent 62934ffb
...@@ -32,13 +32,11 @@ int sidtab_init(struct sidtab *s) ...@@ -32,13 +32,11 @@ int sidtab_init(struct sidtab *s)
int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) int sidtab_insert(struct sidtab *s, u32 sid, struct context *context)
{ {
int hvalue, rc = 0; int hvalue;
struct sidtab_node *prev, *cur, *newnode; struct sidtab_node *prev, *cur, *newnode;
if (!s) { if (!s)
rc = -ENOMEM; return -ENOMEM;
goto out;
}
hvalue = SIDTAB_HASH(sid); hvalue = SIDTAB_HASH(sid);
prev = NULL; prev = NULL;
...@@ -48,21 +46,17 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) ...@@ -48,21 +46,17 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context)
cur = cur->next; cur = cur->next;
} }
if (cur && sid == cur->sid) { if (cur && sid == cur->sid)
rc = -EEXIST; return -EEXIST;
goto out;
}
newnode = kmalloc(sizeof(*newnode), GFP_ATOMIC); newnode = kmalloc(sizeof(*newnode), GFP_ATOMIC);
if (!newnode) { if (!newnode)
rc = -ENOMEM; return -ENOMEM;
goto out;
}
newnode->sid = sid; newnode->sid = sid;
if (context_cpy(&newnode->context, context)) { if (context_cpy(&newnode->context, context)) {
kfree(newnode); kfree(newnode);
rc = -ENOMEM; return -ENOMEM;
goto out;
} }
if (prev) { if (prev) {
...@@ -78,8 +72,7 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) ...@@ -78,8 +72,7 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context)
s->nel++; s->nel++;
if (sid >= s->next_sid) if (sid >= s->next_sid)
s->next_sid = sid + 1; s->next_sid = sid + 1;
out: return 0;
return rc;
} }
static struct context *sidtab_search_core(struct sidtab *s, u32 sid, int force) static struct context *sidtab_search_core(struct sidtab *s, u32 sid, int force)
......
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