Skip to content

Commit

Permalink
selinux: fix return value on error in policydb_read()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Fixes: e67b2ec ("selinux: store role transitions in a hash table")
Signed-off-by: Ondrej Mosnacek <[email protected]>
Signed-off-by: Paul Moore <[email protected]>
  • Loading branch information
WOnder93 authored and pcmoore committed May 1, 2020
1 parent 3348bd3 commit 46619b4
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions security/selinux/ss/policydb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 46619b4

Please sign in to comment.