Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1311713

Re: [PATCH RESEND] bnx2fc:Fix locking requirements before calling the function bnx2fc_alloc_conn_id

From Chad Dupuis <chad.dupuis@qlogic.com>
Newsgroups linux.kernel
Subject Re: [PATCH RESEND] bnx2fc:Fix locking requirements before calling the function bnx2fc_alloc_conn_id
Date 2016-01-18 18:50 +0100
Message-ID <qSm6d-3ZZ-11@gated-at.bofh.it> (permalink)
References <qSm6d-3ZZ-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On Thu, 14 Jan 2016, Nicholas Krause wrote:

> This fixes the locking requirements before calling the function
> bnx2fc_alloc_conn_id by locking the mutex hba_mutex of the
> structure pointer hba in the function bnx2fc_init_tgt as this
> is commented as required to be held by the caller of the function
> bnx2fc_alloc_conn_id. In addition we must also unlock this lock if
> either a error occurs inside the function bnx2fc_alloc_conn_id or
> this function exits successfully in order to avoid deadlock with
> other users of this mutex.
>
> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
> ---
> drivers/scsi/bnx2fc/bnx2fc_tgt.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_tgt.c b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
> index c66c708..41fec79 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_tgt.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
> @@ -368,9 +368,13 @@ static int bnx2fc_init_tgt(struct bnx2fc_rport *tgt,
> 		return -1;
> 	}
>
> +	mutex_lock(&hba->hba_mutex);
> 	tgt->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.

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

Re: [PATCH RESEND] bnx2fc:Fix locking requirements before calling  the function bnx2fc_alloc_conn_id Chad Dupuis <chad.dupuis@qlogic.com> - 2016-01-18 18:50 +0100

csiph-web