2021-01-22 09:39:57

by Abaci Team

[permalink] [raw]
Subject: [PATCH 1/2] scsi: qla2xxx: remove redundant NULL check

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 <[email protected]>
Signed-off-by: Yang Li <[email protected]>
---
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


2021-01-22 19:52:00

by Himanshu Madhani

[permalink] [raw]
Subject: Re: [PATCH 1/2] scsi: qla2xxx: remove redundant NULL check



> On Jan 22, 2021, at 3:02 AM, Yang Li <[email protected]> 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 <[email protected]>
> Signed-off-by: Yang Li <[email protected]>
> ---
> 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 <[email protected]>

--
Himanshu Madhani Oracle Linux Engineering

2021-01-27 21:10:14

by Martin K. Petersen

[permalink] [raw]
Subject: Re: [PATCH 1/2] scsi: qla2xxx: remove redundant NULL check

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