Resend: [PATCH] crypto: don't check for NULL before kfree(), it's redundant.

From: Jesper Juhl
Date: Mon Jun 06 2005 - 18:57:25 EST


Here's a resend of a patch originally for 2.6.12-rc1-mm4. It still
applies to 2.6.12-rc6

The patch removes redundant checks of NULL before kfree() in crypto/ .

Patch attached as well as inline since I don't know how well gmail
handles inline patches.


Signed-off-by: Jesper Juhl <jesper.juhl@xxxxxxxxx>
---

crypto/cipher.c | 3 +--
crypto/hmac.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)

diff -upr linux-2.6.12-rc6-orig/crypto/cipher.c linux-2.6.12-rc6/crypto/cipher.c
--- linux-2.6.12-rc6-orig/crypto/cipher.c 2005-06-07 00:07:12.000000000 +0200
+++ linux-2.6.12-rc6/crypto/cipher.c 2005-06-07 01:49:16.000000000 +0200
@@ -336,6 +336,5 @@ out:

void crypto_exit_cipher_ops(struct crypto_tfm *tfm)
{
- if (tfm->crt_cipher.cit_iv)
- kfree(tfm->crt_cipher.cit_iv);
+ kfree(tfm->crt_cipher.cit_iv);
}
diff -upr linux-2.6.12-rc6-orig/crypto/hmac.c linux-2.6.12-rc6/crypto/hmac.c
--- linux-2.6.12-rc6-orig/crypto/hmac.c 2005-03-02 08:38:09.000000000 +0100
+++ linux-2.6.12-rc6/crypto/hmac.c 2005-06-07 01:49:16.000000000 +0200
@@ -49,8 +49,7 @@ int crypto_alloc_hmac_block(struct crypt

void crypto_free_hmac_block(struct crypto_tfm *tfm)
{
- if (tfm->crt_digest.dit_hmac_block)
- kfree(tfm->crt_digest.dit_hmac_block);
+ kfree(tfm->crt_digest.dit_hmac_block);
}

void crypto_hmac_init(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen)



--
Jesper Juhl <jesper.juhl@xxxxxxxxx>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
diff -upr linux-2.6.12-rc6-orig/crypto/cipher.c linux-2.6.12-rc6/crypto/cipher.c
--- linux-2.6.12-rc6-orig/crypto/cipher.c 2005-06-07 00:07:12.000000000 +0200
+++ linux-2.6.12-rc6/crypto/cipher.c 2005-06-07 01:49:16.000000000 +0200
@@ -336,6 +336,5 @@ out:

void crypto_exit_cipher_ops(struct crypto_tfm *tfm)
{
- if (tfm->crt_cipher.cit_iv)
- kfree(tfm->crt_cipher.cit_iv);
+ kfree(tfm->crt_cipher.cit_iv);
}
diff -upr linux-2.6.12-rc6-orig/crypto/hmac.c linux-2.6.12-rc6/crypto/hmac.c
--- linux-2.6.12-rc6-orig/crypto/hmac.c 2005-03-02 08:38:09.000000000 +0100
+++ linux-2.6.12-rc6/crypto/hmac.c 2005-06-07 01:49:16.000000000 +0200
@@ -49,8 +49,7 @@ int crypto_alloc_hmac_block(struct crypt

void crypto_free_hmac_block(struct crypto_tfm *tfm)
{
- if (tfm->crt_digest.dit_hmac_block)
- kfree(tfm->crt_digest.dit_hmac_block);
+ kfree(tfm->crt_digest.dit_hmac_block);
}

void crypto_hmac_init(struct crypto_tfm *tfm, u8 *key, unsigned int *keylen)