|
Daniel Wagner |
c0442e |
From: Dick Kennedy <dick.kennedy@broadcom.com>
|
|
Daniel Wagner |
c0442e |
Date: Tue, 30 Jun 2020 14:49:48 -0700
|
|
Daniel Wagner |
c0442e |
Subject: scsi: lpfc: Fix unused assignment in lpfc_sli4_bsg_link_diag_test
|
|
Daniel Wagner |
c0442e |
Patch-mainline: Queued in subsystem maintainer repository
|
|
Daniel Wagner |
c0442e |
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git
|
|
Daniel Wagner |
c0442e |
Git-commit: e5fcb81d40d44d3000e5ff8b6c9d87ea36a26faa
|
|
Daniel Wagner |
c0442e |
References: bsc#1172687 bsc#1171530
|
|
Daniel Wagner |
c0442e |
|
|
Daniel Wagner |
c0442e |
Coverity reported the following error:
|
|
Daniel Wagner |
c0442e |
|
|
Daniel Wagner |
c0442e |
Assigned value that is never used may represent unnecessary computation.
|
|
Daniel Wagner |
c0442e |
|
|
Daniel Wagner |
c0442e |
The rc variable was initially assigned a value but in several cases, when
|
|
Daniel Wagner |
c0442e |
an error case is detected, it is reassigned a new value. The initial value
|
|
Daniel Wagner |
c0442e |
had little use.
|
|
Daniel Wagner |
c0442e |
|
|
Daniel Wagner |
c0442e |
In code-reviewing this routine, it could use some cleanup:
|
|
Daniel Wagner |
c0442e |
|
|
Daniel Wagner |
c0442e |
- Setting the initialization value to -ENODEV is a much better choice and
|
|
Daniel Wagner |
c0442e |
lessens code in the routine.
|
|
Daniel Wagner |
c0442e |
|
|
Daniel Wagner |
c0442e |
- The wasn't tracking logic errors vs no error and mailbox failure.
|
|
Daniel Wagner |
c0442e |
Better to resolve by adding a status to track the mailbox failure
|
|
Daniel Wagner |
c0442e |
and merge it with the logic error when the routine returns.
|
|
Daniel Wagner |
c0442e |
|
|
Daniel Wagner |
c0442e |
Link: https://lore.kernel.org/r/20200630215001.70793-2-jsmart2021@gmail.com
|
|
Daniel Wagner |
c0442e |
Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
|
|
Daniel Wagner |
c0442e |
Signed-off-by: James Smart <jsmart2021@gmail.com>
|
|
Daniel Wagner |
c0442e |
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
|
|
Daniel Wagner |
c0442e |
Acked-by: Daniel Wagner <dwagner@suse.de>
|
|
Daniel Wagner |
c0442e |
---
|
|
Daniel Wagner |
c0442e |
drivers/scsi/lpfc/lpfc_bsg.c | 34 ++++++++++++++++------------------
|
|
Daniel Wagner |
c0442e |
1 file changed, 16 insertions(+), 18 deletions(-)
|
|
Daniel Wagner |
c0442e |
|
|
Daniel Wagner |
c0442e |
--- a/drivers/scsi/lpfc/lpfc_bsg.c
|
|
Daniel Wagner |
c0442e |
+++ b/drivers/scsi/lpfc/lpfc_bsg.c
|
|
Daniel Wagner |
c0442e |
@@ -2407,33 +2407,27 @@ lpfc_sli4_bsg_link_diag_test(struct bsg_
|
|
Daniel Wagner |
c0442e |
union lpfc_sli4_cfg_shdr *shdr;
|
|
Daniel Wagner |
c0442e |
uint32_t shdr_status, shdr_add_status;
|
|
Daniel Wagner |
c0442e |
struct diag_status *diag_status_reply;
|
|
Daniel Wagner |
c0442e |
- int mbxstatus, rc = 0;
|
|
Daniel Wagner |
c0442e |
+ int mbxstatus, rc = -ENODEV, rc1 = 0;
|
|
Daniel Wagner |
c0442e |
|
|
Daniel Wagner |
c0442e |
shost = fc_bsg_to_shost(job);
|
|
Daniel Wagner |
c0442e |
- if (!shost) {
|
|
Daniel Wagner |
c0442e |
- rc = -ENODEV;
|
|
Daniel Wagner |
c0442e |
+ if (!shost)
|
|
Daniel Wagner |
c0442e |
goto job_error;
|
|
Daniel Wagner |
c0442e |
- }
|
|
Daniel Wagner |
c0442e |
+
|
|
Daniel Wagner |
c0442e |
vport = shost_priv(shost);
|
|
Daniel Wagner |
c0442e |
- if (!vport) {
|
|
Daniel Wagner |
c0442e |
- rc = -ENODEV;
|
|
Daniel Wagner |
c0442e |
+ if (!vport)
|
|
Daniel Wagner |
c0442e |
goto job_error;
|
|
Daniel Wagner |
c0442e |
- }
|
|
Daniel Wagner |
c0442e |
+
|
|
Daniel Wagner |
c0442e |
phba = vport->phba;
|
|
Daniel Wagner |
c0442e |
- if (!phba) {
|
|
Daniel Wagner |
c0442e |
- rc = -ENODEV;
|
|
Daniel Wagner |
c0442e |
+ if (!phba)
|
|
Daniel Wagner |
c0442e |
goto job_error;
|
|
Daniel Wagner |
c0442e |
- }
|
|
Daniel Wagner |
c0442e |
|
|
Daniel Wagner |
c0442e |
- if (phba->sli_rev < LPFC_SLI_REV4) {
|
|
Daniel Wagner |
c0442e |
- rc = -ENODEV;
|
|
Daniel Wagner |
c0442e |
+
|
|
Daniel Wagner |
c0442e |
+ if (phba->sli_rev < LPFC_SLI_REV4)
|
|
Daniel Wagner |
c0442e |
goto job_error;
|
|
Daniel Wagner |
c0442e |
- }
|
|
Daniel Wagner |
c0442e |
+
|
|
Daniel Wagner |
c0442e |
if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) <
|
|
Daniel Wagner |
c0442e |
- LPFC_SLI_INTF_IF_TYPE_2) {
|
|
Daniel Wagner |
c0442e |
- rc = -ENODEV;
|
|
Daniel Wagner |
c0442e |
+ LPFC_SLI_INTF_IF_TYPE_2)
|
|
Daniel Wagner |
c0442e |
goto job_error;
|
|
Daniel Wagner |
c0442e |
- }
|
|
Daniel Wagner |
c0442e |
|
|
Daniel Wagner |
c0442e |
if (job->request_len < sizeof(struct fc_bsg_request) +
|
|
Daniel Wagner |
c0442e |
sizeof(struct sli4_link_diag)) {
|
|
Daniel Wagner |
c0442e |
@@ -2468,8 +2462,10 @@ lpfc_sli4_bsg_link_diag_test(struct bsg_
|
|
Daniel Wagner |
c0442e |
alloc_len = lpfc_sli4_config(phba, pmboxq, LPFC_MBOX_SUBSYSTEM_FCOE,
|
|
Daniel Wagner |
c0442e |
LPFC_MBOX_OPCODE_FCOE_LINK_DIAG_STATE,
|
|
Daniel Wagner |
c0442e |
req_len, LPFC_SLI4_MBX_EMBED);
|
|
Daniel Wagner |
c0442e |
- if (alloc_len != req_len)
|
|
Daniel Wagner |
c0442e |
+ if (alloc_len != req_len) {
|
|
Daniel Wagner |
c0442e |
+ rc = -ENOMEM;
|
|
Daniel Wagner |
c0442e |
goto link_diag_test_exit;
|
|
Daniel Wagner |
c0442e |
+ }
|
|
Daniel Wagner |
c0442e |
|
|
Daniel Wagner |
c0442e |
run_link_diag_test = &pmboxq->u.mqe.un.link_diag_test;
|
|
Daniel Wagner |
c0442e |
bf_set(lpfc_mbx_run_diag_test_link_num, &run_link_diag_test->u.req,
|
|
Daniel Wagner |
c0442e |
@@ -2518,7 +2514,7 @@ lpfc_sli4_bsg_link_diag_test(struct bsg_
|
|
Daniel Wagner |
c0442e |
diag_status_reply->shdr_add_status = shdr_add_status;
|
|
Daniel Wagner |
c0442e |
|
|
Daniel Wagner |
c0442e |
link_diag_test_exit:
|
|
Daniel Wagner |
c0442e |
- rc = lpfc_sli4_bsg_set_link_diag_state(phba, 0);
|
|
Daniel Wagner |
c0442e |
+ rc1 = lpfc_sli4_bsg_set_link_diag_state(phba, 0);
|
|
Daniel Wagner |
c0442e |
|
|
Daniel Wagner |
c0442e |
if (pmboxq)
|
|
Daniel Wagner |
c0442e |
mempool_free(pmboxq, phba->mbox_mem_pool);
|
|
Daniel Wagner |
c0442e |
@@ -2527,6 +2523,8 @@ lpfc_sli4_bsg_link_diag_test(struct bsg_
|
|
Daniel Wagner |
c0442e |
|
|
Daniel Wagner |
c0442e |
job_error:
|
|
Daniel Wagner |
c0442e |
/* make error code available to userspace */
|
|
Daniel Wagner |
c0442e |
+ if (rc1 && !rc)
|
|
Daniel Wagner |
c0442e |
+ rc = rc1;
|
|
Daniel Wagner |
c0442e |
bsg_reply->result = rc;
|
|
Daniel Wagner |
c0442e |
/* complete the job back to userspace if no error */
|
|
Daniel Wagner |
c0442e |
if (rc == 0)
|