linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] scsi: qla2xxx: remove redundant NULL check
@ 2021-01-22  9:02 Yang Li
  2021-01-22  9:02 ` [PATCH 2/2] scsi: qla4xxx: " Yang Li
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Yang Li @ 2021-01-22  9:02 UTC (permalink / raw)
  To: martin.petersen
  Cc: martin.petersen, njavali, GR-QLogic-Storage-Upstream, mrangankar,
	linux-scsi, linux-kernel, Yang Li

Fix below warnings reported by coccicheck:
./drivers/scsi/qla2xxx/qla_init.c:3371:2-7: WARNING: NULL check before
some freeing functions is not needed.
./drivers/scsi/qla2xxx/qla_init.c:7855:5-10: WARNING: NULL check before
some freeing functions is not needed.
./drivers/scsi/qla2xxx/qla_init.c:7916:2-7: WARNING: NULL check before
some freeing functions is not needed.
./drivers/scsi/qla2xxx/qla_init.c:8113:4-18: WARNING: NULL check before
some freeing functions is not needed.
./drivers/scsi/qla2xxx/qla_init.c:8174:2-7: WARNING: NULL check before
some freeing functions is not needed.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <abaci-bugfix@linux.alibaba.com>
---
 drivers/scsi/qla2xxx/qla_init.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index dcc0f0d8..edd5dd1 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -3371,8 +3371,7 @@ static void qla2x00_tmf_sp_done(srb_t *sp, int res)
 				    "Re-Allocated (%d KB) and save firmware dump.\n",
 				    dump_size / 1024);
 			} else {
-				if (ha->fw_dump)
-					vfree(ha->fw_dump);
+				vfree(ha->fw_dump);
 				ha->fw_dump = fw_dump;
 
 				ha->fw_dump_len = ha->fw_dump_alloc_len =
@@ -7855,8 +7854,7 @@ bool qla24xx_risc_firmware_invalid(uint32_t *dword)
 	templates = (risc_attr & BIT_9) ? 2 : 1;
 	ql_dbg(ql_dbg_init, vha, 0x0160, "-> templates = %u\n", templates);
 	for (j = 0; j < templates; j++, fwdt++) {
-		if (fwdt->template)
-			vfree(fwdt->template);
+		vfree(fwdt->template);
 		fwdt->template = NULL;
 		fwdt->length = 0;
 
@@ -7916,8 +7914,7 @@ bool qla24xx_risc_firmware_invalid(uint32_t *dword)
 	return QLA_SUCCESS;
 
 failed:
-	if (fwdt->template)
-		vfree(fwdt->template);
+	vfree(fwdt->template);
 	fwdt->template = NULL;
 	fwdt->length = 0;
 
@@ -8113,8 +8110,7 @@ bool qla24xx_risc_firmware_invalid(uint32_t *dword)
 	templates = (risc_attr & BIT_9) ? 2 : 1;
 	ql_dbg(ql_dbg_init, vha, 0x0170, "-> templates = %u\n", templates);
 	for (j = 0; j < templates; j++, fwdt++) {
-		if (fwdt->template)
-			vfree(fwdt->template);
+		vfree(fwdt->template);
 		fwdt->template = NULL;
 		fwdt->length = 0;
 
@@ -8174,8 +8170,7 @@ bool qla24xx_risc_firmware_invalid(uint32_t *dword)
 	return QLA_SUCCESS;
 
 failed:
-	if (fwdt->template)
-		vfree(fwdt->template);
+	vfree(fwdt->template);
 	fwdt->template = NULL;
 	fwdt->length = 0;
 
-- 
1.8.3.1


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

* [PATCH 2/2] scsi: qla4xxx: remove redundant NULL check
  2021-01-22  9:02 [PATCH 1/2] scsi: qla2xxx: remove redundant NULL check Yang Li
@ 2021-01-22  9:02 ` Yang Li
  2021-01-22 18:37 ` [PATCH 1/2] scsi: qla2xxx: " Himanshu Madhani
  2021-01-27  4:54 ` Martin K. Petersen
  2 siblings, 0 replies; 5+ messages in thread
From: Yang Li @ 2021-01-22  9:02 UTC (permalink / raw)
  To: martin.petersen
  Cc: martin.petersen, njavali, GR-QLogic-Storage-Upstream, mrangankar,
	linux-scsi, linux-kernel, Yang Li

Fix below warnings reported by coccicheck:
./drivers/scsi/qla4xxx/ql4_os.c:4171:2-7: WARNING: NULL check before
some freeing functions is not needed.
./drivers/scsi/qla4xxx/ql4_os.c:4192:2-7: WARNING: NULL check before
some freeing functions is not needed.
./drivers/scsi/qla4xxx/ql4_os.c:4211:2-7: WARNING: NULL check before
some freeing functions is not needed.
./drivers/scsi/qla4xxx/ql4_os.c:6396:2-7: WARNING: NULL check before
some freeing functions is not needed.
./drivers/scsi/qla4xxx/ql4_os.c:6551:2-7: WARNING: NULL check before
some freeing functions is not needed.
./drivers/scsi/qla4xxx/ql4_os.c:7840:2-7: WARNING: NULL check before
some freeing functions is not needed.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <abaci-bugfix@linux.alibaba.com>
---
 drivers/scsi/qla4xxx/ql4_os.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index a4b014e..73b89fd 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -4171,8 +4171,7 @@ static void qla4xxx_mem_free(struct scsi_qla_host *ha)
 		dma_free_coherent(&ha->pdev->dev, ha->queues_len, ha->queues,
 				  ha->queues_dma);
 
-	if (ha->fw_dump)
-		vfree(ha->fw_dump);
+	vfree(ha->fw_dump);
 
 	ha->queues_len = 0;
 	ha->queues = NULL;
@@ -4192,8 +4191,7 @@ static void qla4xxx_mem_free(struct scsi_qla_host *ha)
 
 	dma_pool_destroy(ha->chap_dma_pool);
 
-	if (ha->chap_list)
-		vfree(ha->chap_list);
+	vfree(ha->chap_list);
 	ha->chap_list = NULL;
 
 	dma_pool_destroy(ha->fw_ddb_dma_pool);
@@ -4211,8 +4209,7 @@ static void qla4xxx_mem_free(struct scsi_qla_host *ha)
 		iounmap(ha->reg);
 	}
 
-	if (ha->reset_tmplt.buff)
-		vfree(ha->reset_tmplt.buff);
+	vfree(ha->reset_tmplt.buff);
 
 	pci_release_regions(ha->pdev);
 }
@@ -6396,10 +6393,8 @@ static int qla4xxx_is_session_exists(struct scsi_qla_host *ha,
 	}
 
 exit_check:
-	if (fw_tddb)
-		vfree(fw_tddb);
-	if (tmp_tddb)
-		vfree(tmp_tddb);
+	vfree(fw_tddb);
+	vfree(tmp_tddb);
 	return ret;
 }
 
@@ -6551,10 +6546,8 @@ static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha,
 	}
 
 exit_check:
-	if (fw_tddb)
-		vfree(fw_tddb);
-	if (tmp_tddb)
-		vfree(tmp_tddb);
+	vfree(fw_tddb);
+	vfree(tmp_tddb);
 	return ret;
 }
 
@@ -7834,10 +7827,8 @@ static int qla4xxx_sysfs_ddb_logout(struct iscsi_bus_flash_session *fnode_sess,
 		ret = -ESRCH;
 
 exit_ddb_logout:
-	if (flash_tddb)
-		vfree(flash_tddb);
-	if (tmp_tddb)
-		vfree(tmp_tddb);
+	vfree(flash_tddb);
+	vfree(tmp_tddb);
 	if (fw_ddb_entry)
 		dma_pool_free(ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma);
 
-- 
1.8.3.1


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

* Re: [PATCH 1/2] scsi: qla2xxx: remove redundant NULL check
  2021-01-22  9:02 [PATCH 1/2] scsi: qla2xxx: remove redundant NULL check Yang Li
  2021-01-22  9:02 ` [PATCH 2/2] scsi: qla4xxx: " Yang Li
@ 2021-01-22 18:37 ` Himanshu Madhani
  2021-01-27  4:54 ` Martin K. Petersen
  2 siblings, 0 replies; 5+ messages in thread
From: Himanshu Madhani @ 2021-01-22 18:37 UTC (permalink / raw)
  To: Yang Li
  Cc: martin.petersen, Martin Petersen, njavali,
	GR-QLogic-Storage-Upstream, mrangankar, linux-scsi, linux-kernel



> On Jan 22, 2021, at 3:02 AM, Yang Li <abaci-bugfix@linux.alibaba.com> wrote:
> 
> Fix below warnings reported by coccicheck:
> ./drivers/scsi/qla2xxx/qla_init.c:3371:2-7: WARNING: NULL check before
> some freeing functions is not needed.
> ./drivers/scsi/qla2xxx/qla_init.c:7855:5-10: WARNING: NULL check before
> some freeing functions is not needed.
> ./drivers/scsi/qla2xxx/qla_init.c:7916:2-7: WARNING: NULL check before
> some freeing functions is not needed.
> ./drivers/scsi/qla2xxx/qla_init.c:8113:4-18: WARNING: NULL check before
> some freeing functions is not needed.
> ./drivers/scsi/qla2xxx/qla_init.c:8174:2-7: WARNING: NULL check before
> some freeing functions is not needed.
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Yang Li <abaci-bugfix@linux.alibaba.com>
> ---
> drivers/scsi/qla2xxx/qla_init.c | 15 +++++----------
> 1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
> index dcc0f0d8..edd5dd1 100644
> --- a/drivers/scsi/qla2xxx/qla_init.c
> +++ b/drivers/scsi/qla2xxx/qla_init.c
> @@ -3371,8 +3371,7 @@ static void qla2x00_tmf_sp_done(srb_t *sp, int res)
> 				    "Re-Allocated (%d KB) and save firmware dump.\n",
> 				    dump_size / 1024);
> 			} else {
> -				if (ha->fw_dump)
> -					vfree(ha->fw_dump);
> +				vfree(ha->fw_dump);
> 				ha->fw_dump = fw_dump;
> 
> 				ha->fw_dump_len = ha->fw_dump_alloc_len =
> @@ -7855,8 +7854,7 @@ bool qla24xx_risc_firmware_invalid(uint32_t *dword)
> 	templates = (risc_attr & BIT_9) ? 2 : 1;
> 	ql_dbg(ql_dbg_init, vha, 0x0160, "-> templates = %u\n", templates);
> 	for (j = 0; j < templates; j++, fwdt++) {
> -		if (fwdt->template)
> -			vfree(fwdt->template);
> +		vfree(fwdt->template);
> 		fwdt->template = NULL;
> 		fwdt->length = 0;
> 
> @@ -7916,8 +7914,7 @@ bool qla24xx_risc_firmware_invalid(uint32_t *dword)
> 	return QLA_SUCCESS;
> 
> failed:
> -	if (fwdt->template)
> -		vfree(fwdt->template);
> +	vfree(fwdt->template);
> 	fwdt->template = NULL;
> 	fwdt->length = 0;
> 
> @@ -8113,8 +8110,7 @@ bool qla24xx_risc_firmware_invalid(uint32_t *dword)
> 	templates = (risc_attr & BIT_9) ? 2 : 1;
> 	ql_dbg(ql_dbg_init, vha, 0x0170, "-> templates = %u\n", templates);
> 	for (j = 0; j < templates; j++, fwdt++) {
> -		if (fwdt->template)
> -			vfree(fwdt->template);
> +		vfree(fwdt->template);
> 		fwdt->template = NULL;
> 		fwdt->length = 0;
> 
> @@ -8174,8 +8170,7 @@ bool qla24xx_risc_firmware_invalid(uint32_t *dword)
> 	return QLA_SUCCESS;
> 
> failed:
> -	if (fwdt->template)
> -		vfree(fwdt->template);
> +	vfree(fwdt->template);
> 	fwdt->template = NULL;
> 	fwdt->length = 0;
> 
> -- 
> 1.8.3.1
> 

Make Sense. 

Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>

--
Himanshu Madhani	 Oracle Linux Engineering


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

* Re: [PATCH 1/2] scsi: qla2xxx: remove redundant NULL check
  2021-01-22  9:02 [PATCH 1/2] scsi: qla2xxx: remove redundant NULL check Yang Li
  2021-01-22  9:02 ` [PATCH 2/2] scsi: qla4xxx: " Yang Li
  2021-01-22 18:37 ` [PATCH 1/2] scsi: qla2xxx: " Himanshu Madhani
@ 2021-01-27  4:54 ` Martin K. Petersen
  2 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2021-01-27  4:54 UTC (permalink / raw)
  To: Yang Li, martin.petersen
  Cc: Martin K . Petersen, linux-kernel, GR-QLogic-Storage-Upstream,
	mrangankar, linux-scsi, njavali

On Fri, 22 Jan 2021 17:02:53 +0800, Yang Li wrote:

> Fix below warnings reported by coccicheck:
> ./drivers/scsi/qla2xxx/qla_init.c:3371:2-7: WARNING: NULL check before
> some freeing functions is not needed.
> ./drivers/scsi/qla2xxx/qla_init.c:7855:5-10: WARNING: NULL check before
> some freeing functions is not needed.
> ./drivers/scsi/qla2xxx/qla_init.c:7916:2-7: WARNING: NULL check before
> some freeing functions is not needed.
> ./drivers/scsi/qla2xxx/qla_init.c:8113:4-18: WARNING: NULL check before
> some freeing functions is not needed.
> ./drivers/scsi/qla2xxx/qla_init.c:8174:2-7: WARNING: NULL check before
> some freeing functions is not needed.

Applied to 5.12/scsi-queue, thanks!

[1/2] scsi: qla2xxx: remove redundant NULL check
      https://git.kernel.org/mkp/scsi/c/18c05faf8ab1

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* [PATCH 1/2] scsi: qla2xxx: remove redundant NULL check
@ 2021-01-22  9:16 Yang Li
  0 siblings, 0 replies; 5+ messages in thread
From: Yang Li @ 2021-01-22  9:16 UTC (permalink / raw)
  To: jejb; +Cc: linux-scsi, linux-kernel, Yang Li

Fix below warnings reported by coccicheck:
./drivers/scsi/qla2xxx/qla_init.c:3371:2-7: WARNING: NULL check before
some freeing functions is not needed.
./drivers/scsi/qla2xxx/qla_init.c:7855:5-10: WARNING: NULL check before
some freeing functions is not needed.
./drivers/scsi/qla2xxx/qla_init.c:7916:2-7: WARNING: NULL check before
some freeing functions is not needed.
./drivers/scsi/qla2xxx/qla_init.c:8113:4-18: WARNING: NULL check before
some freeing functions is not needed.
./drivers/scsi/qla2xxx/qla_init.c:8174:2-7: WARNING: NULL check before
some freeing functions is not needed.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <abaci-bugfix@linux.alibaba.com>
---
 drivers/scsi/qla2xxx/qla_init.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index dcc0f0d8..edd5dd1 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -3371,8 +3371,7 @@ static void qla2x00_tmf_sp_done(srb_t *sp, int res)
 				    "Re-Allocated (%d KB) and save firmware dump.\n",
 				    dump_size / 1024);
 			} else {
-				if (ha->fw_dump)
-					vfree(ha->fw_dump);
+				vfree(ha->fw_dump);
 				ha->fw_dump = fw_dump;
 
 				ha->fw_dump_len = ha->fw_dump_alloc_len =
@@ -7855,8 +7854,7 @@ bool qla24xx_risc_firmware_invalid(uint32_t *dword)
 	templates = (risc_attr & BIT_9) ? 2 : 1;
 	ql_dbg(ql_dbg_init, vha, 0x0160, "-> templates = %u\n", templates);
 	for (j = 0; j < templates; j++, fwdt++) {
-		if (fwdt->template)
-			vfree(fwdt->template);
+		vfree(fwdt->template);
 		fwdt->template = NULL;
 		fwdt->length = 0;
 
@@ -7916,8 +7914,7 @@ bool qla24xx_risc_firmware_invalid(uint32_t *dword)
 	return QLA_SUCCESS;
 
 failed:
-	if (fwdt->template)
-		vfree(fwdt->template);
+	vfree(fwdt->template);
 	fwdt->template = NULL;
 	fwdt->length = 0;
 
@@ -8113,8 +8110,7 @@ bool qla24xx_risc_firmware_invalid(uint32_t *dword)
 	templates = (risc_attr & BIT_9) ? 2 : 1;
 	ql_dbg(ql_dbg_init, vha, 0x0170, "-> templates = %u\n", templates);
 	for (j = 0; j < templates; j++, fwdt++) {
-		if (fwdt->template)
-			vfree(fwdt->template);
+		vfree(fwdt->template);
 		fwdt->template = NULL;
 		fwdt->length = 0;
 
@@ -8174,8 +8170,7 @@ bool qla24xx_risc_firmware_invalid(uint32_t *dword)
 	return QLA_SUCCESS;
 
 failed:
-	if (fwdt->template)
-		vfree(fwdt->template);
+	vfree(fwdt->template);
 	fwdt->template = NULL;
 	fwdt->length = 0;
 
-- 
1.8.3.1


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

end of thread, other threads:[~2021-01-27  5:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22  9:02 [PATCH 1/2] scsi: qla2xxx: remove redundant NULL check Yang Li
2021-01-22  9:02 ` [PATCH 2/2] scsi: qla4xxx: " Yang Li
2021-01-22 18:37 ` [PATCH 1/2] scsi: qla2xxx: " Himanshu Madhani
2021-01-27  4:54 ` Martin K. Petersen
2021-01-22  9:16 Yang Li

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