Commit a0e46db4 authored by Jason Gunthorpe's avatar Jason Gunthorpe

RDMA/cm: Increment the refcount inside cm_find_listen()

All callers need the 'get', so do it in a central place before returning
the pointer.

Link: https://lore.kernel.org/r/20200506074701.9775-11-leon@kernel.orgSigned-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 51e8463c
...@@ -686,9 +686,10 @@ static struct cm_id_private * cm_find_listen(struct ib_device *device, ...@@ -686,9 +686,10 @@ static struct cm_id_private * cm_find_listen(struct ib_device *device,
cm_id_priv = rb_entry(node, struct cm_id_private, service_node); cm_id_priv = rb_entry(node, struct cm_id_private, service_node);
if ((cm_id_priv->id.service_mask & service_id) == if ((cm_id_priv->id.service_mask & service_id) ==
cm_id_priv->id.service_id && cm_id_priv->id.service_id &&
(cm_id_priv->id.device == device)) (cm_id_priv->id.device == device)) {
refcount_inc(&cm_id_priv->refcount);
return cm_id_priv; return cm_id_priv;
}
if (device < cm_id_priv->id.device) if (device < cm_id_priv->id.device)
node = node->rb_left; node = node->rb_left;
else if (device > cm_id_priv->id.device) else if (device > cm_id_priv->id.device)
...@@ -2005,7 +2006,6 @@ static struct cm_id_private * cm_match_req(struct cm_work *work, ...@@ -2005,7 +2006,6 @@ static struct cm_id_private * cm_match_req(struct cm_work *work,
NULL, 0); NULL, 0);
return NULL; return NULL;
} }
refcount_inc(&listen_cm_id_priv->refcount);
spin_unlock_irq(&cm.lock); spin_unlock_irq(&cm.lock);
return listen_cm_id_priv; return listen_cm_id_priv;
} }
...@@ -3564,7 +3564,6 @@ static int cm_sidr_req_handler(struct cm_work *work) ...@@ -3564,7 +3564,6 @@ static int cm_sidr_req_handler(struct cm_work *work)
.status = IB_SIDR_UNSUPPORTED }); .status = IB_SIDR_UNSUPPORTED });
goto out; /* No match. */ goto out; /* No match. */
} }
refcount_inc(&listen_cm_id_priv->refcount);
spin_unlock_irq(&cm.lock); spin_unlock_irq(&cm.lock);
cm_id_priv->id.cm_handler = listen_cm_id_priv->id.cm_handler; cm_id_priv->id.cm_handler = listen_cm_id_priv->id.cm_handler;
......
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