Skip to contentSkip to conversation

selinux: fix error codes in cond_policydb_init()

PATCH Superseded Dan Carpenter 2 participants 2 messages Jun 7, 2010 – Jun 8, 2010

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 5/7 selinux: fix error codes in cond_policydb_init()

It's better to propagate the error code from avtab_init() instead of returning -1 (-EPERM). It turns out that avtab_init() never fails so this patch doesn't change how the code runs but it's still a clean up.

security/selinux/ss/conditional.c +6 -2
index f0de637..7447be0 100644
@@ -117,10 +117,14 @@ int evaluate_cond_node(struct policydb *p, struct cond_node *node)
 
 int cond_policydb_init(struct policydb *p)
 {
+	int ret;
+
 	p->bool_val_to_struct = NULL;
 	p->cond_list = NULL;
-	if (avtab_init(&p->te_cond_avtab))
-		return -1;
+
+	ret = avtab_init(&p->te_cond_avtab);
+	if (ret < 0)
+		return ret;
 
 	return 0;
 }
#1 lore raw
Quoted 11 lines · Dan Carpenter

It's better to propagate the error code from avtab_init() instead of returning -1 (-EPERM).  It turns out that avtab_init() never fails so this patch doesn't change how the code runs but it's still a clean up.

security/selinux/ss/conditional.c +0 -0
index f0de637..7447be0 100644

security/selinux/ss/conditional.c int evaluate_cond_node(struct policydb *p, struct cond_node *node) · line 120

Quoted 4 lines
security/selinux/ss/conditional.c +1 -0
@@ -117,10 +117,14 @@ int evaluate_cond_node(struct policydb *p, struct cond_node *node)
 
  int cond_policydb_init(struct policydb *p)
  {
+       int ret;

I know, I'm being pedantic, but int rc, not int ret; All of the rest of the code uses rc.

security/selinux/ss/conditional.c int evaluate_cond_node(struct policydb *p, struct cond_node *node) · line 126

Quoted 8 lines
security/selinux/ss/conditional.c +4 -2
+
        p->bool_val_to_struct = NULL;
        p->cond_list = NULL;
-       if (avtab_init(&p->te_cond_avtab))
-               return -1;
+
+       ret = avtab_init(&p->te_cond_avtab);
+       if (ret < 0)

if (rc) not if (rc < 0)

security/selinux/ss/conditional.c int evaluate_cond_node(struct policydb *p, struct cond_node *node) · line 130

Quoted 4 lines
security/selinux/ss/conditional.c +1 -0
+               return ret;
 
        return 0;
  }

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