Skip to contentSkip to conversation

selinux: fix return value on error in policydb_read()

PATCH Applied Ondrej Mosnacek 2 participants 2 messages May 1, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

Fixes e67b2ec9f617 ("selinux: store role transitions in a hash table")
---
 security/selinux/ss/policydb.c | 1 +
 1 file changed, 1 insertion(+)
security/selinux/ss/policydb.c +1 -0
index 1c0041576643..9f7ce3e037d1 100644
@@ -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;
Signature · 1 line
2.25.4
maintainer Applied
#1 lore raw
Quoted 11 lines · Ondrej Mosnacek

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.

Fixes e67b2ec9f617 ("selinux: store role transitions in a hash table")
---
 security/selinux/ss/policydb.c | 1 +
 1 file changed, 1 insertion(+)

Here I was just about to reply to your other patches that patch 2/4 looked fine to me but I was going to hold off on applying it until this patch came through :)

Merged into selinux/next, thanks.

Signature · 2 lines
paul moore
www.paul-moore.com