path: root/security/selinux/ss
diff options
authorOndrej Mosnacek <>2020-05-01 21:51:11 +0200
committerPaul Moore <>2020-05-01 16:08:46 -0400
commit46619b44e431d85d64a8dfcb7166d0ae098544c8 (patch)
tree4efa8c85fa18e599d353f1d2e2df7f9e88a44540 /security/selinux/ss
parent3348bd33e8cf8a17138e8ce716ae474ec5d7001e (diff)
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 <> Fixes: e67b2ec9f617 ("selinux: store role transitions in a hash table") Signed-off-by: Ondrej Mosnacek <> Signed-off-by: Paul Moore <>
Diffstat (limited to 'security/selinux/ss')
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;