From 7a2962c77ced218faeeb7b5eda48abfebc578df2 Mon Sep 17 00:00:00 2001 From: Eddie Wai Date: Tue, 23 Nov 2010 15:29:26 -0800 Subject: [PATCH] [SCSI] bnx2i: Added mutex lock protection to conn_get_param Added net_dev mutex lock protection before accessing the csk parameters. Signed-off-by: Eddie Wai Reviewed-by: Benjamin Li Reviewed-by: Mike Christie Signed-off-by: James Bottomley --- drivers/scsi/bnx2i/bnx2i_iscsi.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c index a2c9b1f2ea5c..07dd4f9036f0 100644 --- a/drivers/scsi/bnx2i/bnx2i_iscsi.c +++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c @@ -1461,21 +1461,28 @@ static int bnx2i_conn_get_param(struct iscsi_cls_conn *cls_conn, struct bnx2i_conn *bnx2i_conn = conn->dd_data; int len = 0; + if (!(bnx2i_conn && bnx2i_conn->ep && bnx2i_conn->ep->hba)) + goto out; + switch (param) { case ISCSI_PARAM_CONN_PORT: - if (bnx2i_conn->ep) + mutex_lock(&bnx2i_conn->ep->hba->net_dev_lock); + if (bnx2i_conn->ep->cm_sk) len = sprintf(buf, "%hu\n", bnx2i_conn->ep->cm_sk->dst_port); + mutex_unlock(&bnx2i_conn->ep->hba->net_dev_lock); break; case ISCSI_PARAM_CONN_ADDRESS: - if (bnx2i_conn->ep) + mutex_lock(&bnx2i_conn->ep->hba->net_dev_lock); + if (bnx2i_conn->ep->cm_sk) len = sprintf(buf, "%pI4\n", &bnx2i_conn->ep->cm_sk->dst_ip); + mutex_unlock(&bnx2i_conn->ep->hba->net_dev_lock); break; default: return iscsi_conn_get_param(cls_conn, param, buf); } - +out: return len; } -- 2.30.2