All of lore.kernel.org
 help / color / mirror / Atom feed
* [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; 6+ 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] 6+ messages in thread
* Cocci spatch "ifnullfree" - v4.20-rc4
@ 2018-12-02 20:52 Thomas Meyer
  2018-12-02 20:52 ` [PATCH] scsi: megaraid_sas: NULL check before some freeing functions is not needed Thomas Meyer
  0 siblings, 1 reply; 6+ 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] 6+ messages in thread

end of thread, other threads:[~2018-12-08  2:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-28  8:05 [PATCH] scsi: megaraid_sas: NULL check before some freeing functions is not needed Wen Yang
2018-12-03  6:43 ` Sumit Saxena
2018-12-02 20:52 Cocci spatch "ifnullfree" - v4.20-rc4 Thomas Meyer
2018-12-02 20:52 ` [PATCH] scsi: megaraid_sas: NULL check before some freeing functions is not needed Thomas Meyer
2018-12-03  6:40   ` Sumit Saxena
2018-12-03  6:40     ` Sumit Saxena
2018-12-08  2:40   ` Martin K. Petersen

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.