--- security/selinux/ss/sidtab.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c index 31588d704b98..45a50172f139 100644 --- a/security/selinux/ss/sidtab.c +++ b/security/selinux/ss/sidtab.c @@ -118,27 +118,28 @@ static struct context *sidtab_lookup(struct sidtab *s, u32 sid) return &cur->context; } +static struct context *sidtab_lookup_initial(struct sidtab *s, u32 sid) +{ + return s->isids[sid - 1].set ? &s->isids[sid - 1].context : NULL; +} + static struct context *sidtab_search_core(struct sidtab *s, u32 sid, int force) { struct context *context; - struct sidtab_isid_entry *entry; if (!s) return NULL; if (sid != 0) { - if (sid > SECINITSID_NUM) { + if (sid > SECINITSID_NUM) context = sidtab_lookup(s, sid - (SECINITSID_NUM + 1)); - } else { - entry = &s->isids[sid - 1]; - context = entry->set ? &entry->context : NULL; - } + else + context = sidtab_lookup_initial(s, sid); if (context && (!context->len || force)) return context; } - entry = &s->isids[SECINITSID_UNLABELED - 1]; - return entry->set ? &entry->context : NULL; + return sidtab_lookup_initial(s, SECINITSID_UNLABELED); } struct context *sidtab_search(struct sidtab *s, u32 sid) -- 2.19.2