lkml.org 
[lkml]   [2005]   [Mar]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] don't do pointless NULL checks and casts before kfree() in security/
On Tue, 22 Mar 2005, David Howells wrote:

>
> Jesper Juhl <juhl-lkml@dif.dk> wrote:
>
> > --- linux-2.6.11-mm4-orig/security/keys/key.c 2005-03-16 15:45:42.000000000 +0100
> > +++ linux-2.6.11-mm4/security/keys/key.c 2005-03-20 12:40:19.000000000 +0100
> > ...
> > - if (candidate)
> > - kfree(candidate);
> > + kfree(candidate);
>
> Looks okay to me. It's probably less efficient though, but more space
> efficient.
>
From looking at the code gcc generates it looks to me like the bennefits
of the smaller code should outweigh the overhead of a few more function
calls - especially if the branch is usually taken (which I must admit I
can't really tell if it will be). If the branch is rarely taken you are
probably right.


> > --- linux-2.6.11-mm4-orig/security/keys/user_defined.c 2005-03-16 15:45:42.000000000 +0100
> > +++ linux-2.6.11-mm4/security/keys/user_defined.c 2005-03-20 12:41:54.000000000 +0100
> > @@ -182,9 +182,7 @@ static int user_match(const struct key *
> > */
> > static void user_destroy(struct key *key)
> > {
> > - struct user_key_payload *upayload = key->payload.data;
> > -
> > - kfree(upayload);
> > + kfree(key->payload.data);
>
> There's a patch in Andrew Morton's tree that changes this to make use of RCU,
> so I'd prefer you didn't do this just yet.
>
Huh? I just checked 2.6.12-rc1-mm1, and the user_destroy function still
looks as above... But no problem, I'll just send Andrew the bits in
security/selinux/ for now and wait a bit with the rest.

Thank you for your comments.


--
Jesper

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-04-06 13:30    [W:0.477 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site