linux-kernel.vger.kernel.org archive mirror
 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; 5+ 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] 5+ messages in thread

* Re: [PATCH] scsi: megaraid_sas: NULL check before some freeing functions is not needed
  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
  0 siblings, 0 replies; 5+ messages in thread
From: Sumit Saxena @ 2018-12-03  6:43 UTC (permalink / raw)
  To: wen.yang99
  Cc: Kashyap Desai, Shivasharan Srikanteshwara, LKML, zhong.weidong,
	Julia Lawall

On Wed, Nov 28, 2018 at 1:36 PM Wen Yang <wen.yang99@zte.com.cn> wrote:
>
> 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>

Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>

> 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	[flat|nested] 5+ messages in thread

* Re: [PATCH] scsi: megaraid_sas: NULL check before some freeing functions is not needed.
  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-08  2:40   ` Martin K. Petersen
  1 sibling, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2018-12-08  2:40 UTC (permalink / raw)
  To: Thomas Meyer
  Cc: kashyap.desai, sumit.saxena, shivasharan.srikanteshwara, jejb,
	martin.petersen, megaraidlinux.pdl, linux-scsi, linux-kernel


Thomas,

> NULL check before some freeing functions is not needed.

Applied to 4.21/scsi-queue.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] scsi: megaraid_sas: NULL check before some freeing functions is not needed.
  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-08  2:40   ` Martin K. Petersen
  1 sibling, 0 replies; 5+ messages in thread
From: Sumit Saxena @ 2018-12-03  6:40 UTC (permalink / raw)
  To: thomas
  Cc: Kashyap Desai, Shivasharan Srikanteshwara, James E. J. Bottomley,
	Martin K. Petersen, megaraidlinux.pdl, Linux SCSI List, LKML

On Mon, Dec 3, 2018 at 2:25 AM Thomas Meyer <thomas@m3y3r.de> wrote:
>
> NULL check before some freeing functions is not needed.
>
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>

Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>

> ---
>
> diff -u -p a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
> --- a/drivers/scsi/megaraid/megaraid_mbox.c
> +++ b/drivers/scsi/megaraid/megaraid_mbox.c
> @@ -1243,8 +1243,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;
> @@ -1252,8 +1251,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;
> @@ -1261,8 +1259,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;
>  }
> diff -u -p a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
> --- a/drivers/scsi/megaraid/megaraid_mm.c
> +++ b/drivers/scsi/megaraid/megaraid_mm.c
> @@ -1017,8 +1017,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);
>
> diff -u -p a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
> --- 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_
>
>         }
>
> -       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
>                         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
>                                   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);
>  }
>
>  /**
>
>

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

* [PATCH] scsi: megaraid_sas: NULL check before some freeing functions is not needed.
  2018-12-02 20:52 Cocci spatch "ifnullfree" - v4.20-rc4 Thomas Meyer
@ 2018-12-02 20:52 ` Thomas Meyer
  2018-12-03  6:40   ` Sumit Saxena
  2018-12-08  2:40   ` Martin K. Petersen
  0 siblings, 2 replies; 5+ messages in thread
From: Thomas Meyer @ 2018-12-02 20:52 UTC (permalink / raw)
  To: kashyap.desai, sumit.saxena, shivasharan.srikanteshwara, jejb,
	martin.petersen, megaraidlinux.pdl, linux-scsi, linux-kernel

NULL check before some freeing functions is not needed.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---

diff -u -p a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -1243,8 +1243,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;
@@ -1252,8 +1251,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;
@@ -1261,8 +1259,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;
 }
diff -u -p a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -1017,8 +1017,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);
 
diff -u -p a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
--- 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_
 
 	}
 
-	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
 			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
 				  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);
 }
 
 /**

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

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

Thread overview: 5+ 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-08  2:40   ` Martin K. Petersen

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).