All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: megaraid: fix ifnullfree.cocci warnings
@ 2020-12-11 10:16 ` Julia Lawall
  0 siblings, 0 replies; 10+ messages in thread
From: Julia Lawall @ 2020-12-11 10:16 UTC (permalink / raw)
  To: Kashyap Desai, Sumit Saxena, Shivasharan S, James E.J. Bottomley,
	Martin K. Petersen
  Cc: megaraidlinux.pdl, linux-scsi, linux-kernel, kbuild-all, Denis Efremov

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

NULL check before vfree is not needed.

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

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   33dc9614dc208291d0c4bcdeb5d30d481dcd2c4c
commit: 5e0c074e5b4be02d57d1b60abc3391afe7edd088 coccinelle: ifnullfree: add vfree(), kvfree*() functions
:::::: branch date: 3 hours ago
:::::: commit date: 3 months ago

Please take the patch only if it's a positive warning. Thanks!

 megaraid_sas_fusion.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -3917,8 +3917,7 @@ megasas_free_host_crash_buffer(struct me
 {
 	unsigned int i;
 	for (i = 0; i < instance->drv_buf_alloc; i++) {
-		if (instance->crash_buf[i])
-			vfree(instance->crash_buf[i]);
+		vfree(instance->crash_buf[i]);
 	}
 	instance->drv_buf_index = 0;
 	instance->drv_buf_alloc = 0;

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

* [PATCH] scsi: megaraid: fix ifnullfree.cocci warnings
@ 2020-12-11 10:16 ` Julia Lawall
  0 siblings, 0 replies; 10+ messages in thread
From: Julia Lawall @ 2020-12-11 10:16 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 1172 bytes --]

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

NULL check before vfree is not needed.

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

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@inria.fr>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   33dc9614dc208291d0c4bcdeb5d30d481dcd2c4c
commit: 5e0c074e5b4be02d57d1b60abc3391afe7edd088 coccinelle: ifnullfree: add vfree(), kvfree*() functions
:::::: branch date: 3 hours ago
:::::: commit date: 3 months ago

Please take the patch only if it's a positive warning. Thanks!

 megaraid_sas_fusion.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -3917,8 +3917,7 @@ megasas_free_host_crash_buffer(struct me
 {
 	unsigned int i;
 	for (i = 0; i < instance->drv_buf_alloc; i++) {
-		if (instance->crash_buf[i])
-			vfree(instance->crash_buf[i]);
+		vfree(instance->crash_buf[i]);
 	}
 	instance->drv_buf_index = 0;
 	instance->drv_buf_alloc = 0;

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

* Re: [PATCH] scsi: megaraid: fix ifnullfree.cocci warnings
  2020-12-11 10:16 ` Julia Lawall
@ 2021-01-23  3:25   ` Martin K. Petersen
  -1 siblings, 0 replies; 10+ messages in thread
From: Martin K. Petersen @ 2021-01-23  3:25 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Kashyap Desai, Sumit Saxena, Shivasharan S, James E.J. Bottomley,
	Martin K. Petersen, megaraidlinux.pdl, linux-scsi, linux-kernel,
	kbuild-all, Denis Efremov


Julia,

> NULL check before vfree is not needed.
>
> Generated by: scripts/coccinelle/free/ifnullfree.cocci

Applied to 5.12/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] scsi: megaraid: fix ifnullfree.cocci warnings
@ 2021-01-23  3:25   ` Martin K. Petersen
  0 siblings, 0 replies; 10+ messages in thread
From: Martin K. Petersen @ 2021-01-23  3:25 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 206 bytes --]


Julia,

> NULL check before vfree is not needed.
>
> Generated by: scripts/coccinelle/free/ifnullfree.cocci

Applied to 5.12/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] scsi: megaraid: fix ifnullfree.cocci warnings
  2020-12-11 10:16 ` Julia Lawall
@ 2021-01-27  4:54   ` Martin K. Petersen
  -1 siblings, 0 replies; 10+ messages in thread
From: Martin K. Petersen @ 2021-01-27  4:54 UTC (permalink / raw)
  To: Kashyap Desai, Sumit Saxena, Julia Lawall, James E.J. Bottomley,
	Shivasharan S
  Cc: Martin K . Petersen, linux-kernel, Denis Efremov, linux-scsi,
	megaraidlinux.pdl, kbuild-all

On Fri, 11 Dec 2020 11:16:15 +0100 (CET), Julia Lawall wrote:

> NULL check before vfree is not needed.
> 
> Generated by: scripts/coccinelle/free/ifnullfree.cocci

Applied to 5.12/scsi-queue, thanks!

[1/1] scsi: megaraid: fix ifnullfree.cocci warnings
      https://git.kernel.org/mkp/scsi/c/12e3ef8b3e7c

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] scsi: megaraid: fix ifnullfree.cocci warnings
@ 2021-01-27  4:54   ` Martin K. Petersen
  0 siblings, 0 replies; 10+ messages in thread
From: Martin K. Petersen @ 2021-01-27  4:54 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 367 bytes --]

On Fri, 11 Dec 2020 11:16:15 +0100 (CET), Julia Lawall wrote:

> NULL check before vfree is not needed.
> 
> Generated by: scripts/coccinelle/free/ifnullfree.cocci

Applied to 5.12/scsi-queue, thanks!

[1/1] scsi: megaraid: fix ifnullfree.cocci warnings
      https://git.kernel.org/mkp/scsi/c/12e3ef8b3e7c

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] scsi: megaraid: fix ifnullfree.cocci warnings
  2017-07-25 15:40 ` kbuild test robot
@ 2017-07-25 15:48   ` James Bottomley
  0 siblings, 0 replies; 10+ messages in thread
From: James Bottomley @ 2017-07-25 15:48 UTC (permalink / raw)
  To: kbuild test robot, Romain Perier
  Cc: kbuild-all, Martin K. Petersen, Peter Senna Tschudin,
	Kashyap Desai, Sumit Saxena, Shivasharan S, megaraidlinux.pdl,
	linux-scsi, linux-kernel

On Tue, 2017-07-25 at 23:40 +0800, kbuild test robot wrote:
> drivers/scsi/megaraid/megaraid_sas_fusion.c:608:2-18: 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/scsi/megaraid/megaraid_sas_fusion.c:629:2-18: 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.

Hey, guys, we yelled at Markus Elfring for sending hundreds of patches
like this.  The reason then was too much code churn for too little
value: the if() might be unnecessary but it really doesn't cost very
much in terms of execution time, so the code churn disadvantage greatly
 outweighs any benefits.

The reason hasn't changed, so please stop this otherwise you're going
to turn the very valuable 0day test infrastructure into a thousand
patch spambot.

James

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

* [PATCH] scsi: megaraid: fix ifnullfree.cocci warnings
       [not found] <201707252301.SY4YDAmp%fengguang.wu@intel.com>
@ 2017-07-25 15:40 ` kbuild test robot
  2017-07-25 15:48   ` James Bottomley
  2017-07-25 15:40 ` kbuild test robot
  2017-07-25 15:40 ` kbuild test robot
  2 siblings, 1 reply; 10+ messages in thread
From: kbuild test robot @ 2017-07-25 15:40 UTC (permalink / raw)
  To: Romain Perier
  Cc: kbuild-all, Martin K. Petersen, Peter Senna Tschudin,
	Kashyap Desai, Sumit Saxena, Shivasharan S, James E.J. Bottomley,
	megaraidlinux.pdl, linux-scsi, linux-kernel

drivers/scsi/megaraid/megaraid_sas_fusion.c:608:2-18: 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/scsi/megaraid/megaraid_sas_fusion.c:629:2-18: 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

Fixes: cbb80044a6c7 ("scsi: megaraid: Replace PCI pool old API")
CC: Romain Perier <romain.perier@collabora.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---

 megaraid_sas_fusion.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -604,8 +604,7 @@ megasas_free_rdpq_fusion(struct megasas_
 				fusion->reply_frames_desc_phys[i]);
 	}
 
-	if (fusion->reply_frames_desc_pool)
-		dma_pool_destroy(fusion->reply_frames_desc_pool);
+	dma_pool_destroy(fusion->reply_frames_desc_pool);
 
 	if (fusion->rdpq_virt)
 		pci_free_consistent(instance->pdev,
@@ -625,8 +624,7 @@ megasas_free_reply_fusion(struct megasas
 			fusion->reply_frames_desc[0],
 			fusion->reply_frames_desc_phys[0]);
 
-	if (fusion->reply_frames_desc_pool)
-		dma_pool_destroy(fusion->reply_frames_desc_pool);
+	dma_pool_destroy(fusion->reply_frames_desc_pool);
 
 }
 

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

* [PATCH] scsi: megaraid: fix ifnullfree.cocci warnings
       [not found] <201707252301.SY4YDAmp%fengguang.wu@intel.com>
  2017-07-25 15:40 ` kbuild test robot
@ 2017-07-25 15:40 ` kbuild test robot
  2017-07-25 15:40 ` kbuild test robot
  2 siblings, 0 replies; 10+ messages in thread
From: kbuild test robot @ 2017-07-25 15:40 UTC (permalink / raw)
  To: Romain Perier
  Cc: kbuild-all, Martin K. Petersen, Peter Senna Tschudin,
	Kashyap Desai, Sumit Saxena, Shivasharan S, James E.J. Bottomley,
	megaraidlinux.pdl, linux-scsi, linux-kernel

drivers/scsi/megaraid/megaraid_mbox.c:1256:2-18: 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/scsi/megaraid/megaraid_mbox.c:1265:2-18: 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/scsi/megaraid/megaraid_mbox.c:1274:2-18: 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

Fixes: cbb80044a6c7 ("scsi: megaraid: Replace PCI pool old API")
CC: Romain Perier <romain.perier@collabora.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---

 megaraid_mbox.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -1252,8 +1252,7 @@ megaraid_mbox_teardown_dma_pools(adapter
 		dma_pool_free(raid_dev->sg_pool_handle, sg_pci_blk[i].vaddr,
 			sg_pci_blk[i].dma_addr);
 	}
-	if (raid_dev->sg_pool_handle)
-		dma_pool_destroy(raid_dev->sg_pool_handle);
+	dma_pool_destroy(raid_dev->sg_pool_handle);
 
 
 	epthru_pci_blk = raid_dev->epthru_pool;
@@ -1261,8 +1260,7 @@ megaraid_mbox_teardown_dma_pools(adapter
 		dma_pool_free(raid_dev->epthru_pool_handle,
 			epthru_pci_blk[i].vaddr, epthru_pci_blk[i].dma_addr);
 	}
-	if (raid_dev->epthru_pool_handle)
-		dma_pool_destroy(raid_dev->epthru_pool_handle);
+	dma_pool_destroy(raid_dev->epthru_pool_handle);
 
 
 	mbox_pci_blk = raid_dev->mbox_pool;
@@ -1270,8 +1268,7 @@ megaraid_mbox_teardown_dma_pools(adapter
 		dma_pool_free(raid_dev->mbox_pool_handle,
 			mbox_pci_blk[i].vaddr, mbox_pci_blk[i].dma_addr);
 	}
-	if (raid_dev->mbox_pool_handle)
-		dma_pool_destroy(raid_dev->mbox_pool_handle);
+	dma_pool_destroy(raid_dev->mbox_pool_handle);
 
 	return;
 }

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

* [PATCH] scsi: megaraid: fix ifnullfree.cocci warnings
       [not found] <201707252301.SY4YDAmp%fengguang.wu@intel.com>
  2017-07-25 15:40 ` kbuild test robot
  2017-07-25 15:40 ` kbuild test robot
@ 2017-07-25 15:40 ` kbuild test robot
  2 siblings, 0 replies; 10+ messages in thread
From: kbuild test robot @ 2017-07-25 15:40 UTC (permalink / raw)
  To: Romain Perier
  Cc: kbuild-all, Martin K. Petersen, Peter Senna Tschudin,
	Kashyap Desai, Sumit Saxena, Shivasharan S, James E.J. Bottomley,
	megaraidlinux.pdl, linux-scsi, linux-kernel

drivers/scsi/megaraid/megaraid_mm.c:1020:2-18: 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

Fixes: cbb80044a6c7 ("scsi: megaraid: Replace PCI pool old API")
CC: Romain Perier <romain.perier@collabora.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---

 megaraid_mm.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -1016,8 +1016,7 @@ memalloc_error:
 	kfree(adapter->kioc_list);
 	kfree(adapter->mbox_list);
 
-	if (adapter->pthru_dma_pool)
-		dma_pool_destroy(adapter->pthru_dma_pool);
+	dma_pool_destroy(adapter->pthru_dma_pool);
 
 	kfree(adapter);
 

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

end of thread, other threads:[~2021-01-27  5:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-11 10:16 [PATCH] scsi: megaraid: fix ifnullfree.cocci warnings Julia Lawall
2020-12-11 10:16 ` Julia Lawall
2021-01-23  3:25 ` Martin K. Petersen
2021-01-23  3:25   ` Martin K. Petersen
2021-01-27  4:54 ` Martin K. Petersen
2021-01-27  4:54   ` Martin K. Petersen
     [not found] <201707252301.SY4YDAmp%fengguang.wu@intel.com>
2017-07-25 15:40 ` kbuild test robot
2017-07-25 15:48   ` James Bottomley
2017-07-25 15:40 ` kbuild test robot
2017-07-25 15:40 ` kbuild test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.