bnx2fc:Fix locking requirements before calling the function bnx2fc_alloc_conn_id
A message that is not in the archive (sent off-list or not yet received): [email protected]
Chad Dupuis
NAKQuoted 24 lines · Nicholas Krause
This fixes the locking requirements before calling the function
bnx2fc_alloc_conn_idby locking the mutexhba_mutexof the structure pointer hba in the functionbnx2fc_init_tgtas this is commented as required to be held by the caller of the functionbnx2fc_alloc_conn_id. In addition we must also unlock this lock if either a error occurs inside the functionbnx2fc_alloc_conn_idor this function exits successfully in order to avoid deadlock with other users of this mutex.Signed-off-by Nicholas Krause <[email protected]>---
drivers/scsi/bnx2fc/bnx2fc_tgt.c| 6 +++++-1 file changed, 5 insertions(+), 1 deletion(-)drivers/scsi/bnx2fc/bnx2fc_tgt.c +1
-0@@ -368,9 +368,13 @@ static int bnx2fc_init_tgt(struct bnx2fc_rport *tgt,return -1 ; } +mutex_lock (&hba->hba_mutex);
drivers/scsi/bnx2fc/bnx2fc_tgt.c static int bnx2fc_init_tgt(struct bnx2fc_rport *tgt, · line 380
Quoted 10 lines
drivers/scsi/bnx2fc/bnx2fc_tgt.c +4
-1tgt->fcoe_conn_id =bnx2fc_alloc_conn_id (hba, tgt); -if (tgt->fcoe_conn_id ==-1 ) +if (tgt->fcoe_conn_id ==-1 ) { +mutex_unlock (&hba->hba_mutex);return -1 ; + } +mutex_unlock (&hba->hba_mutex);BNX2FC_TGT_DBG (tgt,"init_tgt - conn_id = 0x%x\n" , tgt->fcoe_conn_id);
Nack, hba->hba_mutex is already taken in the bnx2fc_alloc_conn_id() so there is no need to take it in the caller.