]> err.no Git - linux-2.6/commitdiff
[PATCH] selinux: kfree cleanup
authorJesper Juhl <juhl-lkml@dif.dk>
Sat, 25 Jun 2005 21:58:51 +0000 (14:58 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 25 Jun 2005 23:25:00 +0000 (16:25 -0700)
kfree(NULL) is legal.

Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
security/selinux/hooks.c
security/selinux/selinuxfs.c
security/selinux/ss/conditional.c
security/selinux/ss/policydb.c
security/selinux/ss/services.c

index 932eef18db337293badeb4bf7c96471dcbf7e0e7..17a1189f1ff81c4a1e9f8686ba4f493cb6c96939 100644 (file)
@@ -1658,9 +1658,8 @@ static int selinux_bprm_secureexec (struct linux_binprm *bprm)
 
 static void selinux_bprm_free_security(struct linux_binprm *bprm)
 {
-       struct bprm_security_struct *bsec = bprm->security;
+       kfree(bprm->security);
        bprm->security = NULL;
-       kfree(bsec);
 }
 
 extern struct vfsmount *selinuxfs_mount;
index 07221568b5059dac724b8a2c19cae9ccee6982d8..8eb140dd2e4b3bda4906f717491bb740b4450e50 100644 (file)
@@ -951,8 +951,7 @@ static int sel_make_bools(void)
        u32 sid;
 
        /* remove any existing files */
-       if (bool_pending_values)
-               kfree(bool_pending_values);
+       kfree(bool_pending_values);
 
        sel_remove_bools(dir);
 
@@ -997,10 +996,8 @@ static int sel_make_bools(void)
 out:
        free_page((unsigned long)page);
        if (names) {
-               for (i = 0; i < num; i++) {
-                       if (names[i])
-                               kfree(names[i]);
-               }
+               for (i = 0; i < num; i++)
+                       kfree(names[i]);
                kfree(names);
        }
        return ret;
index b53441184aca727a5a2ba15c14969004cc6c9a15..e2057f5a411a470372efcf919bfa502daa5149d9 100644 (file)
@@ -166,16 +166,14 @@ static void cond_list_destroy(struct cond_node *list)
 
 void cond_policydb_destroy(struct policydb *p)
 {
-       if (p->bool_val_to_struct != NULL)
-               kfree(p->bool_val_to_struct);
+       kfree(p->bool_val_to_struct);
        avtab_destroy(&p->te_cond_avtab);
        cond_list_destroy(p->cond_list);
 }
 
 int cond_init_bool_indexes(struct policydb *p)
 {
-       if (p->bool_val_to_struct)
-               kfree(p->bool_val_to_struct);
+       kfree(p->bool_val_to_struct);
        p->bool_val_to_struct = (struct cond_bool_datum**)
                kmalloc(p->p_bools.nprim * sizeof(struct cond_bool_datum*), GFP_KERNEL);
        if (!p->bool_val_to_struct)
@@ -185,8 +183,7 @@ int cond_init_bool_indexes(struct policydb *p)
 
 int cond_destroy_bool(void *key, void *datum, void *p)
 {
-       if (key)
-               kfree(key);
+       kfree(key);
        kfree(datum);
        return 0;
 }
index 14190efbf333b83c8d270ec83af2d5e7628f21a6..785c33cf486491afc6b2d50d568d5db884b31723 100644 (file)
@@ -590,17 +590,12 @@ void policydb_destroy(struct policydb *p)
                hashtab_destroy(p->symtab[i].table);
        }
 
-       for (i = 0; i < SYM_NUM; i++) {
-               if (p->sym_val_to_name[i])
-                       kfree(p->sym_val_to_name[i]);
-       }
+       for (i = 0; i < SYM_NUM; i++)
+               kfree(p->sym_val_to_name[i]);
 
-       if (p->class_val_to_struct)
-               kfree(p->class_val_to_struct);
-       if (p->role_val_to_struct)
-               kfree(p->role_val_to_struct);
-       if (p->user_val_to_struct)
-               kfree(p->user_val_to_struct);
+       kfree(p->class_val_to_struct);
+       kfree(p->role_val_to_struct);
+       kfree(p->user_val_to_struct);
 
        avtab_destroy(&p->te_avtab);
 
index b6149147d5cb6ef585f09846d03819f454259e45..922bb45054aa415acd3d4efaa24242d85f39d072 100644 (file)
@@ -1705,11 +1705,9 @@ out:
 err:
        if (*names) {
                for (i = 0; i < *len; i++)
-                       if ((*names)[i])
-                               kfree((*names)[i]);
+                       kfree((*names)[i]);
        }
-       if (*values)
-               kfree(*values);
+       kfree(*values);
        goto out;
 }