Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Dan Carpenter and committed by
Paul Moore
6eb4e2b4 d5f3a5f6

+6 -2
+6 -2
security/selinux/ss/policydb.c
··· 289 289 goto out; 290 290 291 291 p->filename_trans = hashtab_create(filenametr_hash, filenametr_cmp, (1 << 10)); 292 - if (!p->filename_trans) 292 + if (!p->filename_trans) { 293 + rc = -ENOMEM; 293 294 goto out; 295 + } 294 296 295 297 p->range_tr = hashtab_create(rangetr_hash, rangetr_cmp, 256); 296 - if (!p->range_tr) 298 + if (!p->range_tr) { 299 + rc = -ENOMEM; 297 300 goto out; 301 + } 298 302 299 303 ebitmap_init(&p->filename_trans_ttypes); 300 304 ebitmap_init(&p->policycaps);