SCSI: esas2r: Static check fixes
Subsystems (2)
cover SCSI: esas2r: Static check fixes
This series of patches fix errors detected by smatch and coccinelle.
Bradley Grove (6):
SCSI: esas2r: smatch - Use biwise rather than logical AND for checking
if any bit set
SCSI: esas2r: smatch - Fix dereference that occurs prior to check
SCSI: esas2r: smatch - Fix dereference that occurs prior to check
SCSI: esas2r: smatch - Fix overrun due to sprintf appending NULL
SCSI: esas2r: smatch - Remove test for impossible condition (uint8 >
255)
SCSI: esas2r: coccinelle - Replace memcpy with struct assignment
drivers/scsi/esas2r/esas2r_flash.c | 11 ++++++++--- drivers/scsi/esas2r/esas2r_init.c | 5 +++-- drivers/scsi/esas2r/esas2r_ioctl.c | 2 +- drivers/scsi/esas2r/esas2r_vda.c | 7 +++++-- 4 files changed, 17 insertions(+), 8 deletions(-)
Signature · 1 line
1.8.1.4
PATCH 1/6 SCSI: esas2r: smatch - Use biwise rather than logical AND for checking if any bit set
--- drivers/scsi/esas2r/esas2r_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/esas2r/esas2r_init.c +1 -1
@@ -808,7 +808,7 @@ static void esas2r_init_pci_cfg_space(struct esas2r_adapter *a)int pcie_cap_reg; pcie_cap_reg =pci_find_capability (a->pcid,PCI_CAP_ID_EXP ); -if (0xffff && pcie_cap_reg) { +if (0xffff & pcie_cap_reg) {u16 devcontrol; pci_read_config_word(a->pcid, pcie_cap_reg + PCI_EXP_DEVCTL,
Signature · 1 line
1.8.1.4
Re: [PATCH 1/6] SCSI: esas2r: smatch - Use biwise rather than logical AND for checking if any bit set
Quoted 1 line · Bradley Grove
Signed-off-by Bradley Grove <[email protected]>
This additional SCSI: in the subject is unnecessary and just causes me extra work to remove it.
There should be a Reported-by: before the signoff indicating whoever you got the report from (it's about the only recognition we give to the static checker people, so it's polite to include it).
I fixed up this current series.
James
PATCH 2/6 SCSI: esas2r: smatch - Fix dereference that occurs prior to check
In reply to Bradley Grove--- drivers/scsi/esas2r/esas2r_init.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/esas2r/esas2r_init.c +2 -1
@@ -665,7 +665,7 @@ void esas2r_kill_adapter(int i)int esas2r_cleanup (struct Scsi_Host *host) { -struct esas2r_adapter *a = (struct esas2r_adapter *)host->hostdata; +struct esas2r_adapter *a;int index;if (host ==NULL ) {
@@ -678,6 +678,7 @@ int esas2r_cleanup(struct Scsi_Host *host) }esas2r_debug ("esas2r_cleanup called for host %p" , host); + a = (struct esas2r_adapter *)host->hostdata; index = a->index;esas2r_kill_adapter (index);return index;
Signature · 1 line
1.8.1.4
PATCH 3/6 SCSI: esas2r: smatch - Fix dereference that occurs prior to check
In reply to Bradley Grove--- drivers/scsi/esas2r/esas2r_flash.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/scsi/esas2r/esas2r_flash.c +6 -1
@@ -860,8 +860,13 @@ bool esas2r_process_fs_ioctl(struct esas2r_adapter *a,return false; } +if (fsc->command >= cmdcnt) { + fs->status =ATTO_STS_INV_FUNC ; +return false; + } + func = cmd_to_fls_func[fsc->command]; -if (fsc->command >= cmdcnt || func ==0xFF ) { +if (func ==0xFF ) { fs->status =ATTO_STS_INV_FUNC ;return false; }
Signature · 1 line
1.8.1.4
PATCH 4/6 SCSI: esas2r: smatch - Fix overrun due to sprintf appending NULL
In reply to Bradley Grove--- drivers/scsi/esas2r/esas2r_vda.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/scsi/esas2r/esas2r_vda.c +5 -2
@@ -302,6 +302,7 @@ static void esas2r_complete_vda_ioctl(struct esas2r_adapter *a,if (vi->cmd.cfg.cfg_func ==VDA_CFG_GET_INIT ) {struct atto_ioctl_vda_cfg_cmd *cfg = &vi->cmd.cfg;struct atto_vda_cfg_rsp *rsp = &rq->func_rsp.cfg_rsp; +char buf[sizeof (cfg->data.init.fw_release) +1 ]; cfg->data_length =cpu_to_le32 (sizeof (struct atto_vda_cfg_init ));
@@ -309,11 +310,13 @@ static void esas2r_complete_vda_ioctl(struct esas2r_adapter *a,le32_to_cpu (rsp->vda_version); cfg->data.init.fw_build = rsp->fw_build; -sprintf ((char *)&cfg->data.init.fw_release, -"%1d.%02d" , +snprintf (buf,sizeof (buf),"%1d.%02d" , (int )LOBYTE (le16_to_cpu (rsp->fw_release)), (int )HIBYTE (le16_to_cpu (rsp->fw_release))); +memcpy (&cfg->data.init.fw_release, buf, +sizeof (cfg->data.init.fw_release)); +if (LOWORD (LOBYTE (cfg->data.init.fw_build)) =='A' ) cfg->data.init.fw_version = cfg->data.init.fw_build;
Signature · 1 line
1.8.1.4
PATCH 5/6 SCSI: esas2r: smatch - Remove test for impossible condition (uint8 > 255)
In reply to Bradley Grove--- drivers/scsi/esas2r/esas2r_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/esas2r/esas2r_ioctl.c +1 -1
@@ -415,7 +415,7 @@ static int csmi_ioctl_callback(struct esas2r_adapter *a, lun = tm->lun; } -if (path >0 || tid >ESAS2R_MAX_ID ) { +if (path >0 ) { rq->func_rsp.ioctl_rsp.csmi.csmi_status =cpu_to_le32 (CSMI_STS_INV_PARAM );return false;
Signature · 1 line
1.8.1.4
PATCH 6/6 SCSI: esas2r: coccinelle - Replace memcpy with struct assignment
In reply to Bradley Grove--- drivers/scsi/esas2r/esas2r_flash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/esas2r/esas2r_flash.c +2 -2
@@ -1360,7 +1360,7 @@ void esas2r_nvram_set_defaults(struct esas2r_adapter *a)u32 time =jiffies_to_msecs (jiffies);esas2r_lock_clear_flags (&a->flags,AF_NVR_VALID ); -memcpy (n, &default_sas_nvram,sizeof (struct esas2r_sas_nvram )); + *n = default_sas_nvram; n->sas_addr[3 ] |=0x0F ; n->sas_addr[4 ] =HIBYTE (LOWORD (time)); n->sas_addr[5 ] =LOBYTE (LOWORD (time));
@@ -1378,7 +1378,7 @@ void esas2r_nvram_get_defaults(struct esas2r_adapter *a,* address out first. */ memcpy (&sas_addr[0 ], a->nvram->sas_addr,8 ); -memcpy (nvram, &default_sas_nvram,sizeof (struct esas2r_sas_nvram )); + *nvram = default_sas_nvram;memcpy (&nvram->sas_addr[0 ], &sas_addr[0 ],8 ); }
Signature · 1 line
1.8.1.4