[PATCH] selinux: kfree cleanup
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>
This commit is contained in:
committed by
Linus Torvalds
parent
a2ba192c96
commit
9a5f04bf79
@@ -1658,9 +1658,8 @@ static int selinux_bprm_secureexec (struct linux_binprm *bprm)
|
|||||||
|
|
||||||
static void selinux_bprm_free_security(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;
|
bprm->security = NULL;
|
||||||
kfree(bsec);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern struct vfsmount *selinuxfs_mount;
|
extern struct vfsmount *selinuxfs_mount;
|
||||||
|
@@ -951,7 +951,6 @@ static int sel_make_bools(void)
|
|||||||
u32 sid;
|
u32 sid;
|
||||||
|
|
||||||
/* remove any existing files */
|
/* remove any existing files */
|
||||||
if (bool_pending_values)
|
|
||||||
kfree(bool_pending_values);
|
kfree(bool_pending_values);
|
||||||
|
|
||||||
sel_remove_bools(dir);
|
sel_remove_bools(dir);
|
||||||
@@ -997,10 +996,8 @@ static int sel_make_bools(void)
|
|||||||
out:
|
out:
|
||||||
free_page((unsigned long)page);
|
free_page((unsigned long)page);
|
||||||
if (names) {
|
if (names) {
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++)
|
||||||
if (names[i])
|
|
||||||
kfree(names[i]);
|
kfree(names[i]);
|
||||||
}
|
|
||||||
kfree(names);
|
kfree(names);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -166,7 +166,6 @@ static void cond_list_destroy(struct cond_node *list)
|
|||||||
|
|
||||||
void cond_policydb_destroy(struct policydb *p)
|
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);
|
avtab_destroy(&p->te_cond_avtab);
|
||||||
cond_list_destroy(p->cond_list);
|
cond_list_destroy(p->cond_list);
|
||||||
@@ -174,7 +173,6 @@ void cond_policydb_destroy(struct policydb *p)
|
|||||||
|
|
||||||
int cond_init_bool_indexes(struct policydb *p)
|
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**)
|
p->bool_val_to_struct = (struct cond_bool_datum**)
|
||||||
kmalloc(p->p_bools.nprim * sizeof(struct cond_bool_datum*), GFP_KERNEL);
|
kmalloc(p->p_bools.nprim * sizeof(struct cond_bool_datum*), GFP_KERNEL);
|
||||||
@@ -185,7 +183,6 @@ int cond_init_bool_indexes(struct policydb *p)
|
|||||||
|
|
||||||
int cond_destroy_bool(void *key, void *datum, void *p)
|
int cond_destroy_bool(void *key, void *datum, void *p)
|
||||||
{
|
{
|
||||||
if (key)
|
|
||||||
kfree(key);
|
kfree(key);
|
||||||
kfree(datum);
|
kfree(datum);
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -590,16 +590,11 @@ void policydb_destroy(struct policydb *p)
|
|||||||
hashtab_destroy(p->symtab[i].table);
|
hashtab_destroy(p->symtab[i].table);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < SYM_NUM; i++) {
|
for (i = 0; i < SYM_NUM; i++)
|
||||||
if (p->sym_val_to_name[i])
|
|
||||||
kfree(p->sym_val_to_name[i]);
|
kfree(p->sym_val_to_name[i]);
|
||||||
}
|
|
||||||
|
|
||||||
if (p->class_val_to_struct)
|
|
||||||
kfree(p->class_val_to_struct);
|
kfree(p->class_val_to_struct);
|
||||||
if (p->role_val_to_struct)
|
|
||||||
kfree(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->user_val_to_struct);
|
||||||
|
|
||||||
avtab_destroy(&p->te_avtab);
|
avtab_destroy(&p->te_avtab);
|
||||||
|
@@ -1705,10 +1705,8 @@ out:
|
|||||||
err:
|
err:
|
||||||
if (*names) {
|
if (*names) {
|
||||||
for (i = 0; i < *len; i++)
|
for (i = 0; i < *len; i++)
|
||||||
if ((*names)[i])
|
|
||||||
kfree((*names)[i]);
|
kfree((*names)[i]);
|
||||||
}
|
}
|
||||||
if (*values)
|
|
||||||
kfree(*values);
|
kfree(*values);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user