Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1628959

[PATCH v3 15/15] staging: ccree: fix ifnullfree.cocci warnings

From Gilad Ben-Yossef <gilad@benyossef.com>
Newsgroups linux.kernel
Subject [PATCH v3 15/15] staging: ccree: fix ifnullfree.cocci warnings
Date 2017-04-23 11:40 +0200
Message-ID <tzm9R-6K4-33@gated-at.bofh.it> (permalink)
References <tzm0a-6Gl-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: kbuild test robot <lkp@intel.com>

drivers/staging/ccree/ssi_hash.c:317:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
drivers/staging/ccree/ssi_hash.c:320:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
drivers/staging/ccree/ssi_hash.c:323:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
drivers/staging/ccree/ssi_hash.c:373:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
drivers/staging/ccree/ssi_hash.c:375:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
drivers/staging/ccree/ssi_hash.c:377:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
drivers/staging/ccree/ssi_hash.c:379:3-8: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
drivers/staging/ccree/ssi_hash.c:381:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
drivers/staging/ccree/ssi_hash.c:383:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.

 NULL check before some freeing functions is not needed.

 Based on checkpatch warning
 "kfree(NULL) is safe this check is probably not required"
 and kfreeaddr.cocci by Julia Lawall.

Generated by: scripts/coccinelle/free/ifnullfree.cocci

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---
 drivers/staging/ccree/ssi_hash.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c
index ab191de..8ff5d4e 100644
--- a/drivers/staging/ccree/ssi_hash.c
+++ b/drivers/staging/ccree/ssi_hash.c
@@ -314,14 +314,11 @@ static int ssi_hash_map_request(struct device *dev,
 		state->digest_buff_dma_addr = 0;
 	}
 fail3:
-	if (state->opad_digest_buff != NULL)
-		kfree(state->opad_digest_buff);
+	kfree(state->opad_digest_buff);
 fail2:
-	if (state->digest_bytes_len != NULL)
-		kfree(state->digest_bytes_len);
+	kfree(state->digest_bytes_len);
 fail1:
-	if (state->digest_buff != NULL)
-		kfree(state->digest_buff);
+	 kfree(state->digest_buff);
 fail_digest_result_buff:
 	 if (state->digest_result_buff != NULL) {
 		 kfree(state->digest_result_buff);
@@ -370,18 +367,12 @@ static void ssi_hash_unmap_request(struct device *dev,
 		state->opad_digest_dma_addr = 0;
 	}
 
-	if (state->opad_digest_buff != NULL)
-		kfree(state->opad_digest_buff);
-	if (state->digest_bytes_len != NULL)
-		kfree(state->digest_bytes_len);
-	if (state->digest_buff != NULL)
-		kfree(state->digest_buff);
-	if (state->digest_result_buff != NULL) 
-	 	kfree(state->digest_result_buff);
-	if (state->buff1 != NULL) 
-		kfree(state->buff1);
-	if (state->buff0 != NULL)
-		kfree(state->buff0);
+	kfree(state->opad_digest_buff);
+	kfree(state->digest_bytes_len);
+	kfree(state->digest_buff);
+	kfree(state->digest_result_buff);
+	kfree(state->buff1);
+	kfree(state->buff0);
 }
 
 static void ssi_hash_unmap_result(struct device *dev, 
-- 
2.1.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3 00/15] staging: ccree: add Arm TrustZone CryptoCell REE driver Gilad Ben-Yossef <gilad@benyossef.com> - 2017-04-23 11:30 +0200
  [PATCH v3 04/15] staging: ccree: add IV generation support Gilad Ben-Yossef <gilad@benyossef.com> - 2017-04-23 11:30 +0200
  [PATCH v3 14/15] staging: ccree: fix ifnullfree.cocci warnings Gilad Ben-Yossef <gilad@benyossef.com> - 2017-04-23 11:40 +0200
  [PATCH v3 10/15] staging: ccree: remove useless NULL test of field Gilad Ben-Yossef <gilad@benyossef.com> - 2017-04-23 11:40 +0200
  [PATCH v3 11/15] staging: ccree: fix platform_no_drv_owner.cocci warnings Gilad Ben-Yossef <gilad@benyossef.com> - 2017-04-23 11:40 +0200
  [PATCH v3 07/15] staging: ccree: add TODO list Gilad Ben-Yossef <gilad@benyossef.com> - 2017-04-23 11:40 +0200
  [PATCH v3 15/15] staging: ccree: fix ifnullfree.cocci warnings Gilad Ben-Yossef <gilad@benyossef.com> - 2017-04-23 11:40 +0200
  [PATCH v3 12/15] staging: ccree: fix semicolon.cocci warnings Gilad Ben-Yossef <gilad@benyossef.com> - 2017-04-23 11:40 +0200
  [PATCH v3 08/15] staging: ccree: add DT bindings for Arm CryptoCell Gilad Ben-Yossef <gilad@benyossef.com> - 2017-04-23 11:40 +0200
  [PATCH v3 09/15] MAINTAINERS: add Gilad BY as ccree maintainer Gilad Ben-Yossef <gilad@benyossef.com> - 2017-04-23 11:40 +0200
  [PATCH v3 13/15] staging: ccree: fix array_size.cocci warnings Gilad Ben-Yossef <gilad@benyossef.com> - 2017-04-23 11:40 +0200

csiph-web