SELinux: fix error code in policydb_init()

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>
This commit is contained in:
Dan Carpenter 2015-02-04 11:34:30 -05:00 коммит произвёл Paul Moore
Родитель d5f3a5f6e7
Коммит 6eb4e2b41b
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -289,12 +289,16 @@ static int policydb_init(struct policydb *p)
goto out; goto out;
p->filename_trans = hashtab_create(filenametr_hash, filenametr_cmp, (1 << 10)); p->filename_trans = hashtab_create(filenametr_hash, filenametr_cmp, (1 << 10));
if (!p->filename_trans) if (!p->filename_trans) {
rc = -ENOMEM;
goto out; goto out;
}
p->range_tr = hashtab_create(rangetr_hash, rangetr_cmp, 256); p->range_tr = hashtab_create(rangetr_hash, rangetr_cmp, 256);
if (!p->range_tr) if (!p->range_tr) {
rc = -ENOMEM;
goto out; goto out;
}
ebitmap_init(&p->filename_trans_ttypes); ebitmap_init(&p->filename_trans_ttypes);
ebitmap_init(&p->policycaps); ebitmap_init(&p->policycaps);