All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] SCSI: esas2r: Static check fixes
@ 2013-08-29 19:55 Bradley Grove
  2013-08-29 19:55 ` [PATCH 1/6] SCSI: esas2r: smatch - Use biwise rather than logical AND for checking if any bit set Bradley Grove
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Bradley Grove @ 2013-08-29 19:55 UTC (permalink / raw)
  To: linux-scsi, jbottomley; +Cc: jseba, dan.carpenter, fengguang.wu, Bradley Grove

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

-- 
1.8.1.4


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

* [PATCH 1/6] SCSI: esas2r: smatch - Use biwise rather than logical AND for checking if any bit set
  2013-08-29 19:55 [PATCH 0/6] SCSI: esas2r: Static check fixes Bradley Grove
@ 2013-08-29 19:55 ` Bradley Grove
  2013-09-06 18:15   ` James Bottomley
  2013-08-29 19:55 ` [PATCH 2/6] SCSI: esas2r: smatch - Fix dereference that occurs prior to check Bradley Grove
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 8+ messages in thread
From: Bradley Grove @ 2013-08-29 19:55 UTC (permalink / raw)
  To: linux-scsi, jbottomley; +Cc: jseba, dan.carpenter, fengguang.wu, Bradley Grove


Signed-off-by: Bradley Grove <bgrove@attotech.com>
---
 drivers/scsi/esas2r/esas2r_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/esas2r/esas2r_init.c b/drivers/scsi/esas2r/esas2r_init.c
index 3a798e7..78b18c1 100644
--- a/drivers/scsi/esas2r/esas2r_init.c
+++ b/drivers/scsi/esas2r/esas2r_init.c
@@ -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,
-- 
1.8.1.4


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

* [PATCH 2/6] SCSI: esas2r: smatch - Fix dereference that occurs prior to check
  2013-08-29 19:55 [PATCH 0/6] SCSI: esas2r: Static check fixes Bradley Grove
  2013-08-29 19:55 ` [PATCH 1/6] SCSI: esas2r: smatch - Use biwise rather than logical AND for checking if any bit set Bradley Grove
@ 2013-08-29 19:55 ` Bradley Grove
  2013-08-29 19:55 ` [PATCH 3/6] " Bradley Grove
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Bradley Grove @ 2013-08-29 19:55 UTC (permalink / raw)
  To: linux-scsi, jbottomley; +Cc: jseba, dan.carpenter, fengguang.wu, Bradley Grove


Signed-off-by: Bradley Grove <bgrove@attotech.com>
---
 drivers/scsi/esas2r/esas2r_init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/esas2r/esas2r_init.c b/drivers/scsi/esas2r/esas2r_init.c
index 78b18c1..9aaad0d 100644
--- a/drivers/scsi/esas2r/esas2r_init.c
+++ b/drivers/scsi/esas2r/esas2r_init.c
@@ -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;
-- 
1.8.1.4


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

* [PATCH 3/6] SCSI: esas2r: smatch - Fix dereference that occurs prior to check
  2013-08-29 19:55 [PATCH 0/6] SCSI: esas2r: Static check fixes Bradley Grove
  2013-08-29 19:55 ` [PATCH 1/6] SCSI: esas2r: smatch - Use biwise rather than logical AND for checking if any bit set Bradley Grove
  2013-08-29 19:55 ` [PATCH 2/6] SCSI: esas2r: smatch - Fix dereference that occurs prior to check Bradley Grove
@ 2013-08-29 19:55 ` Bradley Grove
  2013-08-29 19:55 ` [PATCH 4/6] SCSI: esas2r: smatch - Fix overrun due to sprintf appending NULL Bradley Grove
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Bradley Grove @ 2013-08-29 19:55 UTC (permalink / raw)
  To: linux-scsi, jbottomley; +Cc: jseba, dan.carpenter, fengguang.wu, Bradley Grove


Signed-off-by: Bradley Grove <bgrove@attotech.com>
---
 drivers/scsi/esas2r/esas2r_flash.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/esas2r/esas2r_flash.c b/drivers/scsi/esas2r/esas2r_flash.c
index 8582929..45e353f 100644
--- a/drivers/scsi/esas2r/esas2r_flash.c
+++ b/drivers/scsi/esas2r/esas2r_flash.c
@@ -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;
 	}
-- 
1.8.1.4


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

* [PATCH 4/6] SCSI: esas2r: smatch - Fix overrun due to sprintf appending NULL
  2013-08-29 19:55 [PATCH 0/6] SCSI: esas2r: Static check fixes Bradley Grove
                   ` (2 preceding siblings ...)
  2013-08-29 19:55 ` [PATCH 3/6] " Bradley Grove
@ 2013-08-29 19:55 ` Bradley Grove
  2013-08-29 19:55 ` [PATCH 5/6] SCSI: esas2r: smatch - Remove test for impossible condition (uint8 > 255) Bradley Grove
  2013-08-29 19:55 ` [PATCH 6/6] SCSI: esas2r: coccinelle - Replace memcpy with struct assignment Bradley Grove
  5 siblings, 0 replies; 8+ messages in thread
From: Bradley Grove @ 2013-08-29 19:55 UTC (permalink / raw)
  To: linux-scsi, jbottomley; +Cc: jseba, dan.carpenter, fengguang.wu, Bradley Grove


Signed-off-by: Bradley Grove <bgrove@attotech.com>
---
 drivers/scsi/esas2r/esas2r_vda.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/esas2r/esas2r_vda.c b/drivers/scsi/esas2r/esas2r_vda.c
index f8ec6d6..fd13928 100644
--- a/drivers/scsi/esas2r/esas2r_vda.c
+++ b/drivers/scsi/esas2r/esas2r_vda.c
@@ -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;
-- 
1.8.1.4


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

* [PATCH 5/6] SCSI: esas2r: smatch - Remove test for impossible condition (uint8 > 255)
  2013-08-29 19:55 [PATCH 0/6] SCSI: esas2r: Static check fixes Bradley Grove
                   ` (3 preceding siblings ...)
  2013-08-29 19:55 ` [PATCH 4/6] SCSI: esas2r: smatch - Fix overrun due to sprintf appending NULL Bradley Grove
@ 2013-08-29 19:55 ` Bradley Grove
  2013-08-29 19:55 ` [PATCH 6/6] SCSI: esas2r: coccinelle - Replace memcpy with struct assignment Bradley Grove
  5 siblings, 0 replies; 8+ messages in thread
From: Bradley Grove @ 2013-08-29 19:55 UTC (permalink / raw)
  To: linux-scsi, jbottomley; +Cc: jseba, dan.carpenter, fengguang.wu, Bradley Grove


Signed-off-by: Bradley Grove <bgrove@attotech.com>
---
 drivers/scsi/esas2r/esas2r_ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/esas2r/esas2r_ioctl.c b/drivers/scsi/esas2r/esas2r_ioctl.c
index f3d0cb8..e5b0902 100644
--- a/drivers/scsi/esas2r/esas2r_ioctl.c
+++ b/drivers/scsi/esas2r/esas2r_ioctl.c
@@ -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;
-- 
1.8.1.4


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

* [PATCH 6/6] SCSI: esas2r: coccinelle - Replace memcpy with struct assignment
  2013-08-29 19:55 [PATCH 0/6] SCSI: esas2r: Static check fixes Bradley Grove
                   ` (4 preceding siblings ...)
  2013-08-29 19:55 ` [PATCH 5/6] SCSI: esas2r: smatch - Remove test for impossible condition (uint8 > 255) Bradley Grove
@ 2013-08-29 19:55 ` Bradley Grove
  5 siblings, 0 replies; 8+ messages in thread
From: Bradley Grove @ 2013-08-29 19:55 UTC (permalink / raw)
  To: linux-scsi, jbottomley; +Cc: jseba, dan.carpenter, fengguang.wu, Bradley Grove


Signed-off-by: Bradley Grove <bgrove@attotech.com>
---
 drivers/scsi/esas2r/esas2r_flash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/esas2r/esas2r_flash.c b/drivers/scsi/esas2r/esas2r_flash.c
index 45e353f..2ec3c23 100644
--- a/drivers/scsi/esas2r/esas2r_flash.c
+++ b/drivers/scsi/esas2r/esas2r_flash.c
@@ -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);
 }
 
-- 
1.8.1.4


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

* Re: [PATCH 1/6] SCSI: esas2r: smatch - Use biwise rather than logical AND for checking if any bit set
  2013-08-29 19:55 ` [PATCH 1/6] SCSI: esas2r: smatch - Use biwise rather than logical AND for checking if any bit set Bradley Grove
@ 2013-09-06 18:15   ` James Bottomley
  0 siblings, 0 replies; 8+ messages in thread
From: James Bottomley @ 2013-09-06 18:15 UTC (permalink / raw)
  To: Bradley Grove; +Cc: linux-scsi, jseba, dan.carpenter, fengguang.wu

On Thu, 2013-08-29 at 15:55 -0400, Bradley Grove wrote:
> Signed-off-by: Bradley Grove <bgrove@attotech.com>

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




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

end of thread, other threads:[~2013-09-06 18:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-29 19:55 [PATCH 0/6] SCSI: esas2r: Static check fixes Bradley Grove
2013-08-29 19:55 ` [PATCH 1/6] SCSI: esas2r: smatch - Use biwise rather than logical AND for checking if any bit set Bradley Grove
2013-09-06 18:15   ` James Bottomley
2013-08-29 19:55 ` [PATCH 2/6] SCSI: esas2r: smatch - Fix dereference that occurs prior to check Bradley Grove
2013-08-29 19:55 ` [PATCH 3/6] " Bradley Grove
2013-08-29 19:55 ` [PATCH 4/6] SCSI: esas2r: smatch - Fix overrun due to sprintf appending NULL Bradley Grove
2013-08-29 19:55 ` [PATCH 5/6] SCSI: esas2r: smatch - Remove test for impossible condition (uint8 > 255) Bradley Grove
2013-08-29 19:55 ` [PATCH 6/6] SCSI: esas2r: coccinelle - Replace memcpy with struct assignment Bradley Grove

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.