Skip to content

Commit 6eb4e2b

Browse files
Dan Carpenterpcmoore
authored andcommitted
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>
1 parent d5f3a5f commit 6eb4e2b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

security/selinux/ss/policydb.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,16 @@ static int policydb_init(struct policydb *p)
289289
goto out;
290290

291291
p->filename_trans = hashtab_create(filenametr_hash, filenametr_cmp, (1 << 10));
292-
if (!p->filename_trans)
292+
if (!p->filename_trans) {
293+
rc = -ENOMEM;
293294
goto out;
295+
}
294296

295297
p->range_tr = hashtab_create(rangetr_hash, rangetr_cmp, 256);
296-
if (!p->range_tr)
298+
if (!p->range_tr) {
299+
rc = -ENOMEM;
297300
goto out;
301+
}
298302

299303
ebitmap_init(&p->filename_trans_ttypes);
300304
ebitmap_init(&p->policycaps);

0 commit comments

Comments
 (0)