Re: [PATCH] don't do pointless NULL checks and casts before kfree() in security/

From: David Howells
Date: Tue Mar 22 2005 - 10:42:48 EST



Jesper Juhl <juhl-lkml@xxxxxx> 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.

> --- 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.

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