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