Re: [PATCH] crypto-jitterentropy: Delete unnecessary checks before the function call kzfree

2015-06-25 Thread Herbert Xu
On Tue, Jun 23, 2015 at 11:20:21PM +0200, SF Markus Elfring wrote:
 From: Markus Elfring elfr...@users.sourceforge.net
 Date: Tue, 23 Jun 2015 22:30:21 +0200
 
 The kzfree() function tests whether its argument is NULL and then
 returns immediately. Thus the test around the call is not needed.
 
 This issue was detected by using the Coccinelle software.
 
 Signed-off-by: Markus Elfring elfr...@users.sourceforge.net

Applied.
-- 
Email: Herbert Xu herb...@gondor.apana.org.au
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto-jitterentropy: Delete unnecessary checks before the function call kzfree

2015-06-24 Thread Stephan Mueller
Am Mittwoch, 24. Juni 2015, 10:48:19 schrieb Dan Carpenter:

Hi Dan,

The other NULL assignment isn't useful either.  Also If
entropy_collector is NULL then we would oops calling
kzfree(entropy_collector-mem);
   ^^
Dereference.

I don't understand the patch that you sent.  We shouldn't be introducing
jent_zalloc() or jent_zfree().  Why are you adding abstractions there?

The one C file should have no dependencies on any kernel header files. Thus, 
all links to kernel functions are wrapped.

Quite bad ones as well.

What would you suggest to change?

Thanks.

Ciao
Stephan
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto-jitterentropy: Delete unnecessary checks before the function call kzfree

2015-06-24 Thread Dan Carpenter
Ah.  I should have read the whole thread.  I sort of assumed we were
just adding abstractions for the fun of it (because I have worked in
staging for too long).

regards,
dan carpenter

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto-jitterentropy: Delete unnecessary checks before the function call kzfree

2015-06-24 Thread Dan Carpenter
The other NULL assignment isn't useful either.  Also If
entropy_collector is NULL then we would oops calling
kzfree(entropy_collector-mem);
   ^^
Dereference.

I don't understand the patch that you sent.  We shouldn't be introducing
jent_zalloc() or jent_zfree().  Why are you adding abstractions there?
Quite bad ones as well.

regards,
dan carpenter

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] crypto-jitterentropy: Delete unnecessary checks before the function call kzfree

2015-06-23 Thread SF Markus Elfring
From: Markus Elfring elfr...@users.sourceforge.net
Date: Tue, 23 Jun 2015 22:30:21 +0200

The kzfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
---
 crypto/jitterentropy.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/crypto/jitterentropy.c b/crypto/jitterentropy.c
index d3c3045..22ded3e 100644
--- a/crypto/jitterentropy.c
+++ b/crypto/jitterentropy.c
@@ -698,11 +698,9 @@ static struct rand_data 
*jent_entropy_collector_alloc(unsigned int osr,
 
 static void jent_entropy_collector_free(struct rand_data *entropy_collector)
 {
-   if (entropy_collector-mem)
-   kzfree(entropy_collector-mem);
+   kzfree(entropy_collector-mem);
entropy_collector-mem = NULL;
-   if (entropy_collector)
-   kzfree(entropy_collector);
+   kzfree(entropy_collector);
entropy_collector = NULL;
 }
 
-- 
2.4.4

--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] crypto-jitterentropy: Delete unnecessary checks before the function call kzfree

2015-06-23 Thread Stephan Mueller
Am Dienstag, 23. Juni 2015, 23:20:21 schrieb SF Markus Elfring:

Hi Markus,

 From: Markus Elfring elfr...@users.sourceforge.net
 Date: Tue, 23 Jun 2015 22:30:21 +0200
 
 The kzfree() function tests whether its argument is NULL and then
 returns immediately. Thus the test around the call is not needed.
 
 This issue was detected by using the Coccinelle software.

Ack: the patch is correct and I was overzealous.

Nack: I just proposed a patch earlier today to avoid compiler warnings [1]. 
That patch clashes with yours. May I ask you to wait briefly to see whether 
that patch will be accepted? If yes, it would be great if you could repost the 
patch that applies to the changed code.

PS: when you are at it, maybe even the last line in the function can be 
removed: setting the entropy_collector to NULL at that the end of the function 
is moot as well.

Thanks.

[1] http://lkml.iu.edu/hypermail/linux/kernel/1506.2/05196.html
 
 Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
 ---
  crypto/jitterentropy.c | 6 ++
  1 file changed, 2 insertions(+), 4 deletions(-)
 
 diff --git a/crypto/jitterentropy.c b/crypto/jitterentropy.c
 index d3c3045..22ded3e 100644
 --- a/crypto/jitterentropy.c
 +++ b/crypto/jitterentropy.c
 @@ -698,11 +698,9 @@ static struct rand_data
 *jent_entropy_collector_alloc(unsigned int osr,
 
  static void jent_entropy_collector_free(struct rand_data
 *entropy_collector) {
 - if (entropy_collector-mem)
 - kzfree(entropy_collector-mem);
 + kzfree(entropy_collector-mem);
   entropy_collector-mem = NULL;
 - if (entropy_collector)
 - kzfree(entropy_collector);
 + kzfree(entropy_collector);
   entropy_collector = NULL;
  }


-- 
Ciao
Stephan
--
To unsubscribe from this list: send the line unsubscribe linux-crypto in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html