Commit 153a2e43 authored by Jason Gunthorpe's avatar Jason Gunthorpe

RDMA/cm: Read id.state under lock when doing pr_debug()

The lock should not be dropped before doing the pr_debug() print as it is
accessing data protected by the lock, such as id.state.

Fixes: 119bf817 ("IB/cm: Add debug prints to ib_cm")
Link: https://lore.kernel.org/r/20200310092545.251365-7-leon@kernel.orgSigned-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 98f67156
...@@ -2394,13 +2394,13 @@ static int cm_rep_handler(struct cm_work *work) ...@@ -2394,13 +2394,13 @@ static int cm_rep_handler(struct cm_work *work)
case IB_CM_MRA_REQ_RCVD: case IB_CM_MRA_REQ_RCVD:
break; break;
default: default:
spin_unlock_irq(&cm_id_priv->lock);
ret = -EINVAL; ret = -EINVAL;
pr_debug( pr_debug(
"%s: cm_id_priv->id.state: %d, local_comm_id %d, remote_comm_id %d\n", "%s: cm_id_priv->id.state: %d, local_comm_id %d, remote_comm_id %d\n",
__func__, cm_id_priv->id.state, __func__, cm_id_priv->id.state,
IBA_GET(CM_REP_LOCAL_COMM_ID, rep_msg), IBA_GET(CM_REP_LOCAL_COMM_ID, rep_msg),
IBA_GET(CM_REP_REMOTE_COMM_ID, rep_msg)); IBA_GET(CM_REP_REMOTE_COMM_ID, rep_msg));
spin_unlock_irq(&cm_id_priv->lock);
goto error; goto error;
} }
...@@ -2666,10 +2666,10 @@ int ib_send_cm_drep(struct ib_cm_id *cm_id, ...@@ -2666,10 +2666,10 @@ int ib_send_cm_drep(struct ib_cm_id *cm_id,
cm_id_priv = container_of(cm_id, struct cm_id_private, id); cm_id_priv = container_of(cm_id, struct cm_id_private, id);
spin_lock_irqsave(&cm_id_priv->lock, flags); spin_lock_irqsave(&cm_id_priv->lock, flags);
if (cm_id->state != IB_CM_DREQ_RCVD) { if (cm_id->state != IB_CM_DREQ_RCVD) {
spin_unlock_irqrestore(&cm_id_priv->lock, flags);
kfree(data);
pr_debug("%s: local_id %d, cm_idcm_id->state(%d) != IB_CM_DREQ_RCVD\n", pr_debug("%s: local_id %d, cm_idcm_id->state(%d) != IB_CM_DREQ_RCVD\n",
__func__, be32_to_cpu(cm_id->local_id), cm_id->state); __func__, be32_to_cpu(cm_id->local_id), cm_id->state);
spin_unlock_irqrestore(&cm_id_priv->lock, flags);
kfree(data);
return -EINVAL; return -EINVAL;
} }
...@@ -3005,10 +3005,10 @@ static int cm_rej_handler(struct cm_work *work) ...@@ -3005,10 +3005,10 @@ static int cm_rej_handler(struct cm_work *work)
} }
/* fall through */ /* fall through */
default: default:
spin_unlock_irq(&cm_id_priv->lock);
pr_debug("%s: local_id %d, cm_id_priv->id.state: %d\n", pr_debug("%s: local_id %d, cm_id_priv->id.state: %d\n",
__func__, be32_to_cpu(cm_id_priv->id.local_id), __func__, be32_to_cpu(cm_id_priv->id.local_id),
cm_id_priv->id.state); cm_id_priv->id.state);
spin_unlock_irq(&cm_id_priv->lock);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment