@@ -296,10 +296,9 @@ static int _cm_alloc_response_msg(struct cm_port *port,
0, IB_MGMT_MAD_HDR, IB_MGMT_MAD_DATA,
GFP_ATOMIC,
IB_MGMT_BASE_VERSION);
- if (IS_ERR(m)) {
- ib_destroy_ah(ah);
+ if (IS_ERR(m))
return PTR_ERR(m);
- }
+
m->ah = ah;
*msg = m;
return 0;
@@ -310,13 +309,18 @@ static int cm_alloc_response_msg(struct cm_port *port,
struct ib_mad_send_buf **msg)
{
struct ib_ah *ah;
+ int ret;
ah = ib_create_ah_from_wc(port->mad_agent->qp->pd, mad_recv_wc->wc,
mad_recv_wc->recv_buf.grh, port->port_num);
if (IS_ERR(ah))
return PTR_ERR(ah);
- return _cm_alloc_response_msg(port, mad_recv_wc, ah, msg);
+ ret = _cm_alloc_response_msg(port, mad_recv_wc, ah, msg);
+ if (ret)
+ ib_destroy_ah(ah);
+
+ return ret;
}
static void cm_free_msg(struct ib_mad_send_buf *msg)