2005-10-13 19:27:17

by Jesper Juhl

[permalink] [raw]
Subject: [PATCH 12/14] Big kfree NULL check cleanup - security

This is the security/ part of the big kfree cleanup patch.

Remove pointless checks for NULL prior to calling kfree() in security/.


Sorry about the long Cc: list, but I wanted to make sure I included everyone
who's code I've changed with this patch.


Signed-off-by: Jesper Juhl <[email protected]>
---

Please see the initial announcement mail on LKML with subject
"[PATCH 00/14] Big kfree NULL check cleanup"
for additional details.

security/keys/key.c | 3 +--
security/selinux/ss/policydb.c | 12 ++++++------
2 files changed, 7 insertions(+), 8 deletions(-)

--- linux-2.6.14-rc4-orig/security/keys/key.c 2005-10-11 22:41:35.000000000 +0200
+++ linux-2.6.14-rc4/security/keys/key.c 2005-10-13 11:47:59.000000000 +0200
@@ -114,8 +114,7 @@ struct key_user *key_user_lookup(uid_t u
found:
atomic_inc(&user->usage);
spin_unlock(&key_user_lock);
- if (candidate)
- kfree(candidate);
+ kfree(candidate);
out:
return user;

--- linux-2.6.14-rc4-orig/security/selinux/ss/policydb.c 2005-10-11 22:41:35.000000000 +0200
+++ linux-2.6.14-rc4/security/selinux/ss/policydb.c 2005-10-13 11:49:17.000000000 +0200
@@ -633,22 +633,22 @@ void policydb_destroy(struct policydb *p
cond_policydb_destroy(p);

for (tr = p->role_tr; tr; tr = tr->next) {
- if (ltr) kfree(ltr);
+ kfree(ltr);
ltr = tr;
}
- if (ltr) kfree(ltr);
+ kfree(ltr);

for (ra = p->role_allow; ra; ra = ra -> next) {
- if (lra) kfree(lra);
+ kfree(lra);
lra = ra;
}
- if (lra) kfree(lra);
+ kfree(lra);

for (rt = p->range_tr; rt; rt = rt -> next) {
- if (lrt) kfree(lrt);
+ kfree(lrt);
lrt = rt;
}
- if (lrt) kfree(lrt);
+ kfree(lrt);

for (i = 0; i < p->p_types.nprim; i++)
ebitmap_destroy(&p->type_attr_map[i]);




2005-10-13 20:03:22

by James Morris

[permalink] [raw]
Subject: Re: [PATCH 12/14] Big kfree NULL check cleanup - security

On Thu, 13 Oct 2005, Jesper Juhl wrote:

> This is the security/ part of the big kfree cleanup patch.
>
> Remove pointless checks for NULL prior to calling kfree() in security/.
>
>
> Sorry about the long Cc: list, but I wanted to make sure I included everyone
> who's code I've changed with this patch.
>
>
> Signed-off-by: Jesper Juhl <[email protected]>

Acked-by: James Morris <[email protected]>

--
James Morris
<[email protected]>