[PATCH] scsi: megaraid_sas: NULL check before some freeing functions is not needed

From: Wen Yang
Date: Wed Nov 28 2018 - 03:06:13 EST


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@xxxxxxxxxx>
CC: Julia Lawall <julia.lawall@xxxxxxx>
CC: Kashyap Desai <kashyap.desai@xxxxxxxxxxxx>
CC: Sumit Saxena <sumit.saxena@xxxxxxxxxxxx>
CC: Shivasharan S <shivasharan.srikanteshwara@xxxxxxxxxxxx>
CC: linux-kernel@xxxxxxxxxxxxxxx
---
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