summaryrefslogtreecommitdiff
path: root/security/selinux
diff options
context:
space:
mode:
authorOndrej Mosnacek <omosnace@redhat.com>2020-05-01 22:51:11 +0300
committerPaul Moore <paul@paul-moore.com>2020-05-01 23:08:46 +0300
commit46619b44e431d85d64a8dfcb7166d0ae098544c8 (patch)
tree4efa8c85fa18e599d353f1d2e2df7f9e88a44540 /security/selinux
parent3348bd33e8cf8a17138e8ce716ae474ec5d7001e (diff)
downloadlinux-46619b44e431d85d64a8dfcb7166d0ae098544c8.tar.xz
selinux: fix return value on error in policydb_read()
The value of rc is still zero from the last assignment when the error path is taken. Fix it by setting it to -ENOMEM before the hashtab_create() call. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Fixes: e67b2ec9f617 ("selinux: store role transitions in a hash table") Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security/selinux')
-rw-r--r--security/selinux/ss/policydb.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index 8a287a7afd9f..76358c9de129 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -2540,6 +2540,7 @@ int policydb_read(struct policydb *p, void *fp)
goto bad;
nel = le32_to_cpu(buf[0]);
+ rc = -ENOMEM;
p->role_tr = hashtab_create(role_trans_hash, role_trans_cmp, nel);
if (!p->role_tr)
goto bad;