[PATCH] scsi: csiostor: remove 'state' parameter from csio_do_hello()

Nikolay Kulikov <[email protected]>
Newsgroups org.kernel.vger.linux-scsi,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
At the single call site, the 'state' parameter holds the address of the
'hw->fw_state' field. However, the csio_do_hello() also receives a
pointer to 'hw', so use that field directly to avoid unnecessary pointer
check.

Detected by Smatch:
drivers/scsi/csiostor/csio_hw.c:1007 csio_do_hello()
	warn: variable dereferenced before check 'state' (see line 954)

Signed-off-by: Nikolay Kulikov <[email protected]>
---
 drivers/scsi/csiostor/csio_hw.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/csiostor/csio_hw.c b/drivers/scsi/csiostor/csio_hw.c
index df9f81f29950..ea3775161d7b 100644
--- a/drivers/scsi/csiostor/csio_hw.c
+++ b/drivers/scsi/csiostor/csio_hw.c
@@ -908,12 +908,11 @@ csio_hw_dev_ready(struct csio_hw *hw)
 /*
  * csio_do_hello - Perform the HELLO FW Mailbox command and process response.
  * @hw: HW module
- * @state: Device state
  *
  * FW_HELLO_CMD has to be polled for completion.
  */
 static int
-csio_do_hello(struct csio_hw *hw, enum csio_dev_state *state)
+csio_do_hello(struct csio_hw *hw)
 {
 	struct csio_mb	*mbp;
 	int	rv = 0;
@@ -941,7 +940,7 @@ csio_do_hello(struct csio_hw *hw, enum csio_dev_state *state)
 		goto out_free_mb;
 	}
 
-	csio_mb_process_hello_rsp(hw, mbp, &retval, state, &mpfn);
+	csio_mb_process_hello_rsp(hw, mbp, &retval, &hw->fw_state, &mpfn);
 	if (retval != FW_SUCCESS) {
 		csio_err(hw, "HELLO cmd failed with ret: %d\n", retval);
 		rv = -EINVAL;
@@ -951,7 +950,7 @@ csio_do_hello(struct csio_hw *hw, enum csio_dev_state *state)
 	/* Firmware has designated us to be master */
 	if (hw->pfn == mpfn) {
 		hw->flags |= CSIO_HWF_MASTER;
-	} else if (*state == CSIO_DEV_STATE_UNINIT) {
+	} else if (hw->fw_state == CSIO_DEV_STATE_UNINIT) {
 		/*
 		 * If we're not the Master PF then we need to wait around for
 		 * the Master PF Driver to finish setting up the adapter.
@@ -1004,12 +1003,11 @@ csio_do_hello(struct csio_hw *hw, enum csio_dev_state *state)
 			 * We either have an Error or Initialized condition
 			 * report errors preferentially.
 			 */
-			if (state) {
-				if (pcie_fw & PCIE_FW_ERR_F) {
-					*state = CSIO_DEV_STATE_ERR;
-					rv = -ETIMEDOUT;
-				} else if (pcie_fw & PCIE_FW_INIT_F)
-					*state = CSIO_DEV_STATE_INIT;
+			if (pcie_fw & PCIE_FW_ERR_F) {
+				hw->fw_state = CSIO_DEV_STATE_ERR;
+				rv = -ETIMEDOUT;
+			} else if (pcie_fw & PCIE_FW_INIT_F) {
+				hw->fw_state = CSIO_DEV_STATE_INIT;
 			}
 
 			/*
@@ -1025,7 +1023,7 @@ csio_do_hello(struct csio_hw *hw, enum csio_dev_state *state)
 		hw->flags &= ~CSIO_HWF_MASTER;
 	}
 
-	switch (*state) {
+	switch (hw->fw_state) {
 	case CSIO_DEV_STATE_UNINIT:
 		strcpy(state_str, "Initializing");
 		break;
@@ -2511,7 +2509,7 @@ csio_hw_configure(struct csio_hw *hw)
 
 	csio_hw_print_fw_version(hw, "Firmware revision");
 
-	rv = csio_do_hello(hw, &hw->fw_state);
+	rv = csio_do_hello(hw);
 	if (rv != 0) {
 		CSIO_INC_STATS(hw, n_err_fatal);
 		csio_post_event(&hw->sm, CSIO_HWE_FATAL);

---
base-commit: 12e67eb89eb2b9516685c744d3f7de0a2d1bd701
change-id: 20260824-scsi_csio_state-8cc1d80fcf89

Best regards,
--  
Nikolay Kulikov <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.