Commit 0c4386ec authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

IB/{cm, umad}: Handle av init error

cm_init_av_for_response depends on ib_init_ah_from_wc() whose return
status is ignored.
ib_init_ah_from_wc() can fail and its return status should be handled as
done in this patch.
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Reviewed-by: default avatarDaniel Jurgens <danielj@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent dbb12562
...@@ -452,12 +452,12 @@ static void cm_set_private_data(struct cm_id_private *cm_id_priv, ...@@ -452,12 +452,12 @@ static void cm_set_private_data(struct cm_id_private *cm_id_priv,
cm_id_priv->private_data_len = private_data_len; cm_id_priv->private_data_len = private_data_len;
} }
static void cm_init_av_for_response(struct cm_port *port, struct ib_wc *wc, static int cm_init_av_for_response(struct cm_port *port, struct ib_wc *wc,
struct ib_grh *grh, struct cm_av *av) struct ib_grh *grh, struct cm_av *av)
{ {
av->port = port; av->port = port;
av->pkey_index = wc->pkey_index; av->pkey_index = wc->pkey_index;
ib_init_ah_from_wc(port->cm_dev->ib_device, port->port_num, wc, return ib_init_ah_from_wc(port->cm_dev->ib_device, port->port_num, wc,
grh, &av->ah_attr); grh, &av->ah_attr);
} }
...@@ -1860,9 +1860,11 @@ static int cm_req_handler(struct cm_work *work) ...@@ -1860,9 +1860,11 @@ static int cm_req_handler(struct cm_work *work)
cm_id_priv = container_of(cm_id, struct cm_id_private, id); cm_id_priv = container_of(cm_id, struct cm_id_private, id);
cm_id_priv->id.remote_id = req_msg->local_comm_id; cm_id_priv->id.remote_id = req_msg->local_comm_id;
cm_init_av_for_response(work->port, work->mad_recv_wc->wc, ret = cm_init_av_for_response(work->port, work->mad_recv_wc->wc,
work->mad_recv_wc->recv_buf.grh, work->mad_recv_wc->recv_buf.grh,
&cm_id_priv->av); &cm_id_priv->av);
if (ret)
goto destroy;
cm_id_priv->timewait_info = cm_create_timewait_info(cm_id_priv-> cm_id_priv->timewait_info = cm_create_timewait_info(cm_id_priv->
id.local_id); id.local_id);
if (IS_ERR(cm_id_priv->timewait_info)) { if (IS_ERR(cm_id_priv->timewait_info)) {
...@@ -3205,9 +3207,11 @@ static int cm_lap_handler(struct cm_work *work) ...@@ -3205,9 +3207,11 @@ static int cm_lap_handler(struct cm_work *work)
cm_id_priv->id.lap_state = IB_CM_LAP_RCVD; cm_id_priv->id.lap_state = IB_CM_LAP_RCVD;
cm_id_priv->tid = lap_msg->hdr.tid; cm_id_priv->tid = lap_msg->hdr.tid;
cm_init_av_for_response(work->port, work->mad_recv_wc->wc, ret = cm_init_av_for_response(work->port, work->mad_recv_wc->wc,
work->mad_recv_wc->recv_buf.grh, work->mad_recv_wc->recv_buf.grh,
&cm_id_priv->av); &cm_id_priv->av);
if (ret)
goto unlock;
cm_init_av_by_path(param->alternate_path, &cm_id_priv->alt_av, cm_init_av_by_path(param->alternate_path, &cm_id_priv->alt_av,
cm_id_priv); cm_id_priv);
ret = atomic_inc_and_test(&cm_id_priv->work_count); ret = atomic_inc_and_test(&cm_id_priv->work_count);
...@@ -3460,6 +3464,7 @@ static int cm_sidr_req_handler(struct cm_work *work) ...@@ -3460,6 +3464,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
struct cm_id_private *cm_id_priv, *cur_cm_id_priv; struct cm_id_private *cm_id_priv, *cur_cm_id_priv;
struct cm_sidr_req_msg *sidr_req_msg; struct cm_sidr_req_msg *sidr_req_msg;
struct ib_wc *wc; struct ib_wc *wc;
int ret;
cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL); cm_id = ib_create_cm_id(work->port->cm_dev->ib_device, NULL, NULL);
if (IS_ERR(cm_id)) if (IS_ERR(cm_id))
...@@ -3472,9 +3477,12 @@ static int cm_sidr_req_handler(struct cm_work *work) ...@@ -3472,9 +3477,12 @@ static int cm_sidr_req_handler(struct cm_work *work)
wc = work->mad_recv_wc->wc; wc = work->mad_recv_wc->wc;
cm_id_priv->av.dgid.global.subnet_prefix = cpu_to_be64(wc->slid); cm_id_priv->av.dgid.global.subnet_prefix = cpu_to_be64(wc->slid);
cm_id_priv->av.dgid.global.interface_id = 0; cm_id_priv->av.dgid.global.interface_id = 0;
cm_init_av_for_response(work->port, work->mad_recv_wc->wc, ret = cm_init_av_for_response(work->port, work->mad_recv_wc->wc,
work->mad_recv_wc->recv_buf.grh, work->mad_recv_wc->recv_buf.grh,
&cm_id_priv->av); &cm_id_priv->av);
if (ret)
goto out;
cm_id_priv->id.remote_id = sidr_req_msg->request_id; cm_id_priv->id.remote_id = sidr_req_msg->request_id;
cm_id_priv->tid = sidr_req_msg->hdr.tid; cm_id_priv->tid = sidr_req_msg->hdr.tid;
atomic_inc(&cm_id_priv->work_count); atomic_inc(&cm_id_priv->work_count);
......
...@@ -246,10 +246,14 @@ static void recv_handler(struct ib_mad_agent *agent, ...@@ -246,10 +246,14 @@ static void recv_handler(struct ib_mad_agent *agent,
if (packet->mad.hdr.grh_present) { if (packet->mad.hdr.grh_present) {
struct rdma_ah_attr ah_attr; struct rdma_ah_attr ah_attr;
const struct ib_global_route *grh; const struct ib_global_route *grh;
int ret;
ib_init_ah_from_wc(agent->device, agent->port_num, ret = ib_init_ah_from_wc(agent->device, agent->port_num,
mad_recv_wc->wc, mad_recv_wc->recv_buf.grh, mad_recv_wc->wc,
mad_recv_wc->recv_buf.grh,
&ah_attr); &ah_attr);
if (ret)
goto err2;
grh = rdma_ah_read_grh(&ah_attr); grh = rdma_ah_read_grh(&ah_attr);
packet->mad.hdr.gid_index = grh->sgid_index; packet->mad.hdr.gid_index = grh->sgid_index;
......
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