mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] remove NULL check before kfree
@ 2017-08-26 21:15 Himanshu Jha
  2017-08-26 21:15 ` [PATCH 1/2] crypto: n2 - remove null " Himanshu Jha
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Himanshu Jha @ 2017-08-26 21:15 UTC (permalink / raw)
  To: herbert; +Cc: davem, linux-crypto, linux-kernel, Himanshu Jha

*** BLURB HERE ***

Himanshu Jha (2):
  crypto: n2 - remove null check before kfree
  crypto: inside-secure - remove null check before kfree

 drivers/crypto/inside-secure/safexcel_hash.c |  6 ++----
 drivers/crypto/n2_core.c                     | 12 ++++--------
 2 files changed, 6 insertions(+), 12 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] crypto: n2 - remove null check before kfree
  2017-08-26 21:15 [PATCH 0/2] remove NULL check before kfree Himanshu Jha
@ 2017-08-26 21:15 ` Himanshu Jha
  2017-08-27  1:49   ` David Miller
  2017-08-26 21:15 ` [PATCH 2/2] crypto: inside-secure " Himanshu Jha
  2017-09-22 10:15 ` [PATCH 0/2] remove NULL " Herbert Xu
  2 siblings, 1 reply; 5+ messages in thread
From: Himanshu Jha @ 2017-08-26 21:15 UTC (permalink / raw)
  To: herbert; +Cc: davem, linux-crypto, linux-kernel, Himanshu Jha

kfree on NULL pointer is a no-op and therefore checking it is redundant.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
---
 drivers/crypto/n2_core.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/crypto/n2_core.c b/drivers/crypto/n2_core.c
index a9fd8b9..48de52c 100644
--- a/drivers/crypto/n2_core.c
+++ b/drivers/crypto/n2_core.c
@@ -1962,10 +1962,8 @@ static struct n2_crypto *alloc_n2cp(void)
 
 static void free_n2cp(struct n2_crypto *np)
 {
-	if (np->cwq_info.ino_table) {
-		kfree(np->cwq_info.ino_table);
-		np->cwq_info.ino_table = NULL;
-	}
+	kfree(np->cwq_info.ino_table);
+	np->cwq_info.ino_table = NULL;
 
 	kfree(np);
 }
@@ -2079,10 +2077,8 @@ static struct n2_mau *alloc_ncp(void)
 
 static void free_ncp(struct n2_mau *mp)
 {
-	if (mp->mau_info.ino_table) {
-		kfree(mp->mau_info.ino_table);
-		mp->mau_info.ino_table = NULL;
-	}
+	kfree(mp->mau_info.ino_table);
+	mp->mau_info.ino_table = NULL;
 
 	kfree(mp);
 }
-- 
2.7.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] crypto: inside-secure - remove null check before kfree
  2017-08-26 21:15 [PATCH 0/2] remove NULL check before kfree Himanshu Jha
  2017-08-26 21:15 ` [PATCH 1/2] crypto: n2 - remove null " Himanshu Jha
@ 2017-08-26 21:15 ` Himanshu Jha
  2017-09-22 10:15 ` [PATCH 0/2] remove NULL " Herbert Xu
  2 siblings, 0 replies; 5+ messages in thread
From: Himanshu Jha @ 2017-08-26 21:15 UTC (permalink / raw)
  To: herbert; +Cc: davem, linux-crypto, linux-kernel, Himanshu Jha

Kfree on NULL pointer is a no-op and therefore checking is redundant.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
---
 drivers/crypto/inside-secure/safexcel_hash.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c
index 3f81939..9c32bbb 100644
--- a/drivers/crypto/inside-secure/safexcel_hash.c
+++ b/drivers/crypto/inside-secure/safexcel_hash.c
@@ -308,10 +308,8 @@ static int safexcel_ahash_send(struct crypto_async_request *async, int ring,
 		ctx->base.cache_sz = 0;
 	}
 free_cache:
-	if (ctx->base.cache) {
-		kfree(ctx->base.cache);
-		ctx->base.cache = NULL;
-	}
+	kfree(ctx->base.cache);
+	ctx->base.cache = NULL;
 
 unlock:
 	spin_unlock_bh(&priv->ring[ring].egress_lock);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] crypto: n2 - remove null check before kfree
  2017-08-26 21:15 ` [PATCH 1/2] crypto: n2 - remove null " Himanshu Jha
@ 2017-08-27  1:49   ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2017-08-27  1:49 UTC (permalink / raw)
  To: himanshujha199640; +Cc: herbert, linux-crypto, linux-kernel

From: Himanshu Jha <himanshujha199640@gmail.com>
Date: Sun, 27 Aug 2017 02:45:29 +0530

> kfree on NULL pointer is a no-op and therefore checking it is redundant.
> 
> Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] remove NULL check before kfree
  2017-08-26 21:15 [PATCH 0/2] remove NULL check before kfree Himanshu Jha
  2017-08-26 21:15 ` [PATCH 1/2] crypto: n2 - remove null " Himanshu Jha
  2017-08-26 21:15 ` [PATCH 2/2] crypto: inside-secure " Himanshu Jha
@ 2017-09-22 10:15 ` Herbert Xu
  2 siblings, 0 replies; 5+ messages in thread
From: Herbert Xu @ 2017-09-22 10:15 UTC (permalink / raw)
  To: Himanshu Jha; +Cc: davem, linux-crypto, linux-kernel

On Sun, Aug 27, 2017 at 02:45:28AM +0530, Himanshu Jha wrote:
> *** BLURB HERE ***
> 
> Himanshu Jha (2):
>   crypto: n2 - remove null check before kfree
>   crypto: inside-secure - remove null check before kfree

All applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-09-22 10:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-26 21:15 [PATCH 0/2] remove NULL check before kfree Himanshu Jha
2017-08-26 21:15 ` [PATCH 1/2] crypto: n2 - remove null " Himanshu Jha
2017-08-27  1:49   ` David Miller
2017-08-26 21:15 ` [PATCH 2/2] crypto: inside-secure " Himanshu Jha
2017-09-22 10:15 ` [PATCH 0/2] remove NULL " Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®