Skip to content

Commit

Permalink
SELinux: fix error code in policydb_init()
Browse files Browse the repository at this point in the history
If hashtab_create() returns a NULL pointer then we should return -ENOMEM
but instead the current code returns success.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Acked-by:  Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Paul Moore <pmoore@redhat.com>
  • Loading branch information
Dan Carpenter authored and Paul Moore committed Feb 4, 2015
1 parent d5f3a5f commit 6eb4e2b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions security/selinux/ss/policydb.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,16 @@ static int policydb_init(struct policydb *p)
goto out;

p->filename_trans = hashtab_create(filenametr_hash, filenametr_cmp, (1 << 10));
if (!p->filename_trans)
if (!p->filename_trans) {
rc = -ENOMEM;
goto out;
}

p->range_tr = hashtab_create(rangetr_hash, rangetr_cmp, 256);
if (!p->range_tr)
if (!p->range_tr) {
rc = -ENOMEM;
goto out;
}

ebitmap_init(&p->filename_trans_ttypes);
ebitmap_init(&p->policycaps);
Expand Down

0 comments on commit 6eb4e2b

Please sign in to comment.