linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Cocci spatch "ifnullfree" - v4.20-rc4
@ 2018-12-02 20:52 Thomas Meyer
  2018-12-02 20:52 ` [PATCH] scsi: NULL check before some freeing functions is not needed Thomas Meyer
                   ` (15 more replies)
  0 siblings, 16 replies; 32+ messages in thread
From: Thomas Meyer @ 2018-12-02 20:52 UTC (permalink / raw)
  To: linux-kernel

NULL check before some freeing functions is not needed.

Found by coccinelle spatch "free/ifnullfree.cocci"

Run against version v4.20-rc4

P.S. If you find this email unwanted, set up a procmail rule junking on
the header:

X-Patch: Cocci

^ permalink raw reply	[flat|nested] 32+ messages in thread
* [PATCH] scsi: megaraid_sas: NULL check before some freeing functions is not needed
@ 2018-11-28  8:05 Wen Yang
  2018-12-03  6:43 ` Sumit Saxena
  0 siblings, 1 reply; 32+ messages in thread
From: Wen Yang @ 2018-11-28  8:05 UTC (permalink / raw)
  To: kashyap.desai, sumit.saxena, shivasharan.srikanteshwara
  Cc: linux-kernel, zhong.weidong, Wen Yang, Julia Lawall

dma_pool_destroy(NULL) is safe, so removes NULL check before freeing
the mem. This patch also fix the ifnullfree.cocci warnings.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
CC: Julia Lawall <julia.lawall@lip6.fr>
CC: Kashyap Desai <kashyap.desai@broadcom.com>
CC: Sumit Saxena <sumit.saxena@broadcom.com>
CC: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
CC: linux-kernel@vger.kernel.org
---
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index f74b5ea24f0f..aa477f09a7a5 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -807,10 +807,8 @@ megasas_free_rdpq_fusion(struct megasas_instance *instance) {
 
 	}
 
-	if (fusion->reply_frames_desc_pool)
-		dma_pool_destroy(fusion->reply_frames_desc_pool);
-	if (fusion->reply_frames_desc_pool_align)
-		dma_pool_destroy(fusion->reply_frames_desc_pool_align);
+	dma_pool_destroy(fusion->reply_frames_desc_pool);
+	dma_pool_destroy(fusion->reply_frames_desc_pool_align);
 
 	if (fusion->rdpq_virt)
 		dma_free_coherent(&instance->pdev->dev,
@@ -830,8 +828,7 @@ megasas_free_reply_fusion(struct megasas_instance *instance) {
 			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);
 
 }
 
@@ -1627,8 +1624,7 @@ static inline void megasas_free_ioc_init_cmd(struct megasas_instance *instance)
 				  fusion->ioc_init_cmd->frame,
 				  fusion->ioc_init_cmd->frame_phys_addr);
 
-	if (fusion->ioc_init_cmd)
-		kfree(fusion->ioc_init_cmd);
+	kfree(fusion->ioc_init_cmd);
 }
 
 /**
-- 
2.19.1


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

end of thread, other threads:[~2018-12-17 11:46 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-02 20:52 Cocci spatch "ifnullfree" - v4.20-rc4 Thomas Meyer
2018-12-02 20:52 ` [PATCH] scsi: NULL check before some freeing functions is not needed Thomas Meyer
2018-12-02 20:52 ` [PATCH] drm/amdgpu: " Thomas Meyer
2018-12-03 11:51   ` Koenig, Christian
2018-12-02 20:52 ` [PATCH] scsi: aic7xxx: " Thomas Meyer
2018-12-02 20:52 ` [PATCH] dlm: " Thomas Meyer
2018-12-02 20:52 ` [PATCH] [SCSI] zfcp: " Thomas Meyer
2018-12-03 10:59   ` Steffen Maier
2018-12-02 20:52 ` [PATCH] scsi: megaraid_sas: " Thomas Meyer
2018-12-03  6:40   ` Sumit Saxena
2018-12-08  2:40   ` Martin K. Petersen
2018-12-02 20:52 ` [PATCH] KVM: PPC: Book3S HV: " Thomas Meyer
2018-12-03  0:06   ` Suraj Jitindar Singh
2018-12-02 20:52 ` [PATCH] PM / AVS: SmartReflex: " Thomas Meyer
2018-12-11 18:53   ` Kevin Hilman
2018-12-17 11:45     ` Rafael J. Wysocki
2018-12-02 20:52 ` [PATCH] scsi: lpfc: " Thomas Meyer
2018-12-02 20:52 ` [PATCH] scsi: qla4xxx: " Thomas Meyer
2018-12-03  5:48   ` Rangankar, Manish
2018-12-02 20:52 ` [PATCH] scsi: qedf: " Thomas Meyer
2018-12-03  5:57   ` Rangankar, Manish
2018-12-08  2:41   ` Martin K. Petersen
2018-12-02 20:52 ` [PATCH] scsi: mpt3sas: " Thomas Meyer
2018-12-02 20:52 ` [PATCH] platform/x86: intel_ips: " Thomas Meyer
2018-12-03 19:10   ` Andy Shevchenko
2018-12-02 20:52 ` [PATCH] scsi: qla2xxx: " Thomas Meyer
2018-12-03 18:07   ` [EXT] " Madhani, Himanshu
2018-12-08  2:47   ` Martin K. Petersen
2018-12-02 20:52 ` [PATCH] scsi: ipr: " Thomas Meyer
2018-12-02 20:52 ` [PATCH] scsi: csiostor: " Thomas Meyer
  -- strict thread matches above, loose matches on Subject: below --
2018-11-28  8:05 [PATCH] scsi: megaraid_sas: " Wen Yang
2018-12-03  6:43 ` Sumit Saxena

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).