Skip to content

Commit 34a2dab

Browse files
WOnder93pcmoore
authored andcommitted
selinux: clean up error path in policydb_init()
Commit e0ac568 ("selinux: reduce the use of hard-coded hash sizes") moved symtab initialization out of policydb_init(), but left the cleanup of symtabs from the error path. This patch fixes the oversight. Suggested-by: Stephen Smalley <[email protected]> Signed-off-by: Ondrej Mosnacek <[email protected]> Acked-by: Stephen Smalley <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent e3e0b58 commit 34a2dab

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

security/selinux/ss/policydb.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -463,36 +463,28 @@ static int rangetr_cmp(struct hashtab *h, const void *k1, const void *k2)
463463
*/
464464
static int policydb_init(struct policydb *p)
465465
{
466-
int i, rc;
466+
int rc;
467467

468468
memset(p, 0, sizeof(*p));
469469

470470
rc = avtab_init(&p->te_avtab);
471471
if (rc)
472-
goto out;
472+
return rc;
473473

474474
rc = cond_policydb_init(p);
475475
if (rc)
476-
goto out;
476+
return rc;
477477

478478
p->filename_trans = hashtab_create(filenametr_hash, filenametr_cmp,
479479
(1 << 11));
480-
if (!p->filename_trans) {
481-
rc = -ENOMEM;
482-
goto out;
483-
}
480+
if (!p->filename_trans)
481+
return -ENOMEM;
484482

485483
ebitmap_init(&p->filename_trans_ttypes);
486484
ebitmap_init(&p->policycaps);
487485
ebitmap_init(&p->permissive_map);
488486

489487
return 0;
490-
out:
491-
for (i = 0; i < SYM_NUM; i++) {
492-
hashtab_map(p->symtab[i].table, destroy_f[i], NULL);
493-
hashtab_destroy(p->symtab[i].table);
494-
}
495-
return rc;
496488
}
497489

498490
/*

0 commit comments

Comments
 (0)