Skip to contentSkip to conversation

SELinux: fix error code in policydb_init()

PATCH In review Dan Carpenter 4 participants 4 messages Jan 28, 2015 – Jan 29, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

security/selinux/ss/policydb.c +6 -2
index bc2a586..74aa224 100644
@@ -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);
Acked-by Serge Hallyn on v1 1/1
#1 lore raw
Quoted 4 lines · Dan Carpenter

If hashtab_create() returns a NULL pointer then we should return -ENOMEM but instead the current code returns success.

Quoted 24 lines
security/selinux/ss/policydb.c +6 -2
index bc2a586..74aa224 100644
@@ -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);
Acked-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 4 lines · Dan Carpenter

If hashtab_create() returns a NULL pointer then we should return -ENOMEM but instead the current code returns success.

Quoted 29 lines
security/selinux/ss/policydb.c +6 -3
index bc2a586..74aa224 100644
@@ -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);
--

To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#3 lore raw
In reply to Dan Carpenter
Quoted 4 lines · Dan Carpenter

If hashtab_create() returns a NULL pointer then we should return -ENOMEM but instead the current code returns success.

Merged. Nice catch, thanks for submitting.

Quoted 23 lines
security/selinux/ss/policydb.c +6 -1
index bc2a586..74aa224 100644
@@ -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);
Signature · 2 lines
paul moore
www.paul-moore.com