The check is better and is fine to accept. However, in reviewing the code, there may still be some raciness as some of the fields validated aren't set under lock. We'll look deeper. Regardless, holding the lock while counting is a very good thing to do.

Signed-off-by: James Smart <[email protected]>

-- james


On 7/18/2016 7:06 AM, Johannes Thumshirn wrote:
Call lpfc_sli_validate_fcp_iocb() with the hbalock held, as the pointer to
iocbq is not guaranteed to still be valid after looking it up.

Signed-off-by: Johannes Thumshirn <[email protected]>
---
  drivers/scsi/lpfc/lpfc_sli.c | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 1a248a2..d58ec4c 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -9978,6 +9978,7 @@ lpfc_sli_sum_iocb(struct lpfc_vport *vport, uint16_t 
tgt_id, uint64_t lun_id,
        struct lpfc_iocbq *iocbq;
        int sum, i;
+ spin_lock_irq(&phba->hbalock);
        for (i = 1, sum = 0; i <= phba->sli.last_iotag; i++) {
                iocbq = phba->sli.iocbq_lookup[i];
@@ -9985,6 +9986,7 @@ lpfc_sli_sum_iocb(struct lpfc_vport *vport, uint16_t tgt_id, uint64_t lun_id,
                                                ctx_cmd) == 0)
                        sum++;
        }
+       spin_unlock_irq(&phba->hbalock);
return sum;
  }

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to