diff mbox series

scsi: qla2xxx: NULL check before some freeing functions is not needed.

Message ID 1543760930052-275330559-13-diffsplit-thomas@m3y3r.de (mailing list archive)
State Accepted
Commit 75c1d48a338bdf3ce850166be527598017e0ebca
Headers show
Series scsi: qla2xxx: NULL check before some freeing functions is not needed. | expand

Commit Message

Thomas Meyer Dec. 2, 2018, 8:52 p.m. UTC
NULL check before some freeing functions is not needed.

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

Comments

Madhani, Himanshu Dec. 3, 2018, 6:07 p.m. UTC | #1
> On Dec 2, 2018, at 12:52 PM, Thomas Meyer <thomas@m3y3r.de> wrote:
> 
> External Email
> 
> ----------------------------------------------------------------------
> External Email
> 
> NULL check before some freeing functions is not needed.
> 
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
> ---
> 
> diff -u -p a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> --- a/drivers/scsi/qla2xxx/qla_os.c
> +++ b/drivers/scsi/qla2xxx/qla_os.c
> @@ -4191,12 +4191,10 @@ fail_free_nvram:
>        kfree(ha->nvram);
>        ha->nvram = NULL;
> fail_free_ctx_mempool:
> -       if (ha->ctx_mempool)
> -               mempool_destroy(ha->ctx_mempool);
> +       mempool_destroy(ha->ctx_mempool);
>        ha->ctx_mempool = NULL;
> fail_free_srb_mempool:
> -       if (ha->srb_mempool)
> -               mempool_destroy(ha->srb_mempool);
> +       mempool_destroy(ha->srb_mempool);
>        ha->srb_mempool = NULL;
> fail_free_gid_list:
>        dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha),
> @@ -4498,8 +4496,7 @@ qla2x00_mem_free(struct qla_hw_data *ha)
>                dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump,
>                    ha->mctp_dump_dma);
> 
> -       if (ha->srb_mempool)
> -               mempool_destroy(ha->srb_mempool);
> +       mempool_destroy(ha->srb_mempool);
> 
>        if (ha->dcbx_tlv)
>                dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE,
> @@ -4531,8 +4528,7 @@ qla2x00_mem_free(struct qla_hw_data *ha)
>        if (ha->async_pd)
>                dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma);
> 
> -       if (ha->s_dma_pool)
> -               dma_pool_destroy(ha->s_dma_pool);
> +       dma_pool_destroy(ha->s_dma_pool);
> 
>        if (ha->gid_list)
>                dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha),
> @@ -4553,14 +4549,11 @@ qla2x00_mem_free(struct qla_hw_data *ha)
>                }
>        }
> 
> -       if (ha->dl_dma_pool)
> -               dma_pool_destroy(ha->dl_dma_pool);
> +       dma_pool_destroy(ha->dl_dma_pool);
> 
> -       if (ha->fcp_cmnd_dma_pool)
> -               dma_pool_destroy(ha->fcp_cmnd_dma_pool);
> +       dma_pool_destroy(ha->fcp_cmnd_dma_pool);
> 
> -       if (ha->ctx_mempool)
> -               mempool_destroy(ha->ctx_mempool);
> +       mempool_destroy(ha->ctx_mempool);
> 
>        qlt_mem_free(ha);
> 
> @@ -7106,8 +7099,7 @@ qla2x00_module_exit(void)
>        qla2x00_release_firmware();
>        kmem_cache_destroy(srb_cachep);
>        qlt_exit();
> -       if (ctx_cachep)
> -               kmem_cache_destroy(ctx_cachep);
> +       kmem_cache_destroy(ctx_cachep);
>        fc_release_transport(qla2xxx_transport_template);
>        fc_release_transport(qla2xxx_transport_vport_template);
> }

Looks good. 

Acked-by: Himanshu Madhani <hmadhani@marvell.com>

Thanks,
- Himanshu
Martin K. Petersen Dec. 8, 2018, 2:47 a.m. UTC | #2
Thomas,

> NULL check before some freeing functions is not needed.

Applied to 4.21/scsi-queue.
diff mbox series

Patch

diff -u -p a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -4191,12 +4191,10 @@  fail_free_nvram:
 	kfree(ha->nvram);
 	ha->nvram = NULL;
 fail_free_ctx_mempool:
-	if (ha->ctx_mempool)
-		mempool_destroy(ha->ctx_mempool);
+	mempool_destroy(ha->ctx_mempool);
 	ha->ctx_mempool = NULL;
 fail_free_srb_mempool:
-	if (ha->srb_mempool)
-		mempool_destroy(ha->srb_mempool);
+	mempool_destroy(ha->srb_mempool);
 	ha->srb_mempool = NULL;
 fail_free_gid_list:
 	dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha),
@@ -4498,8 +4496,7 @@  qla2x00_mem_free(struct qla_hw_data *ha)
 		dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump,
 		    ha->mctp_dump_dma);
 
-	if (ha->srb_mempool)
-		mempool_destroy(ha->srb_mempool);
+	mempool_destroy(ha->srb_mempool);
 
 	if (ha->dcbx_tlv)
 		dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE,
@@ -4531,8 +4528,7 @@  qla2x00_mem_free(struct qla_hw_data *ha)
 	if (ha->async_pd)
 		dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma);
 
-	if (ha->s_dma_pool)
-		dma_pool_destroy(ha->s_dma_pool);
+	dma_pool_destroy(ha->s_dma_pool);
 
 	if (ha->gid_list)
 		dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha),
@@ -4553,14 +4549,11 @@  qla2x00_mem_free(struct qla_hw_data *ha)
 		}
 	}
 
-	if (ha->dl_dma_pool)
-		dma_pool_destroy(ha->dl_dma_pool);
+	dma_pool_destroy(ha->dl_dma_pool);
 
-	if (ha->fcp_cmnd_dma_pool)
-		dma_pool_destroy(ha->fcp_cmnd_dma_pool);
+	dma_pool_destroy(ha->fcp_cmnd_dma_pool);
 
-	if (ha->ctx_mempool)
-		mempool_destroy(ha->ctx_mempool);
+	mempool_destroy(ha->ctx_mempool);
 
 	qlt_mem_free(ha);
 
@@ -7106,8 +7099,7 @@  qla2x00_module_exit(void)
 	qla2x00_release_firmware();
 	kmem_cache_destroy(srb_cachep);
 	qlt_exit();
-	if (ctx_cachep)
-		kmem_cache_destroy(ctx_cachep);
+	kmem_cache_destroy(ctx_cachep);
 	fc_release_transport(qla2xxx_transport_template);
 	fc_release_transport(qla2xxx_transport_vport_template);
 }