Commit 3b12f73a authored by Zhu Yanjun's avatar Zhu Yanjun Committed by David S. Miller

rds: ib: add error handle

In the function rds_ib_setup_qp, the error handle is missing. When some
error occurs, it is possible that memory leak occurs. As such, error
handle is added.

Cc: Joe Jin <joe.jin@oracle.com>
Reviewed-by: default avatarJunxiao Bi <junxiao.bi@oracle.com>
Reviewed-by: default avatarGuanglei Li <guanglei.li@oracle.com>
Signed-off-by: default avatarZhu Yanjun <yanjun.zhu@oracle.com>
Acked-by: default avatarSantosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 67e303e0
...@@ -442,7 +442,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn) ...@@ -442,7 +442,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
ic->i_send_cq = NULL; ic->i_send_cq = NULL;
ibdev_put_vector(rds_ibdev, ic->i_scq_vector); ibdev_put_vector(rds_ibdev, ic->i_scq_vector);
rdsdebug("ib_create_cq send failed: %d\n", ret); rdsdebug("ib_create_cq send failed: %d\n", ret);
goto out; goto rds_ibdev_out;
} }
ic->i_rcq_vector = ibdev_get_unused_vector(rds_ibdev); ic->i_rcq_vector = ibdev_get_unused_vector(rds_ibdev);
...@@ -456,19 +456,19 @@ static int rds_ib_setup_qp(struct rds_connection *conn) ...@@ -456,19 +456,19 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
ic->i_recv_cq = NULL; ic->i_recv_cq = NULL;
ibdev_put_vector(rds_ibdev, ic->i_rcq_vector); ibdev_put_vector(rds_ibdev, ic->i_rcq_vector);
rdsdebug("ib_create_cq recv failed: %d\n", ret); rdsdebug("ib_create_cq recv failed: %d\n", ret);
goto out; goto send_cq_out;
} }
ret = ib_req_notify_cq(ic->i_send_cq, IB_CQ_NEXT_COMP); ret = ib_req_notify_cq(ic->i_send_cq, IB_CQ_NEXT_COMP);
if (ret) { if (ret) {
rdsdebug("ib_req_notify_cq send failed: %d\n", ret); rdsdebug("ib_req_notify_cq send failed: %d\n", ret);
goto out; goto recv_cq_out;
} }
ret = ib_req_notify_cq(ic->i_recv_cq, IB_CQ_SOLICITED); ret = ib_req_notify_cq(ic->i_recv_cq, IB_CQ_SOLICITED);
if (ret) { if (ret) {
rdsdebug("ib_req_notify_cq recv failed: %d\n", ret); rdsdebug("ib_req_notify_cq recv failed: %d\n", ret);
goto out; goto recv_cq_out;
} }
/* XXX negotiate max send/recv with remote? */ /* XXX negotiate max send/recv with remote? */
...@@ -494,7 +494,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn) ...@@ -494,7 +494,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
ret = rdma_create_qp(ic->i_cm_id, ic->i_pd, &attr); ret = rdma_create_qp(ic->i_cm_id, ic->i_pd, &attr);
if (ret) { if (ret) {
rdsdebug("rdma_create_qp failed: %d\n", ret); rdsdebug("rdma_create_qp failed: %d\n", ret);
goto out; goto recv_cq_out;
} }
ic->i_send_hdrs = ib_dma_alloc_coherent(dev, ic->i_send_hdrs = ib_dma_alloc_coherent(dev,
...@@ -504,7 +504,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn) ...@@ -504,7 +504,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
if (!ic->i_send_hdrs) { if (!ic->i_send_hdrs) {
ret = -ENOMEM; ret = -ENOMEM;
rdsdebug("ib_dma_alloc_coherent send failed\n"); rdsdebug("ib_dma_alloc_coherent send failed\n");
goto out; goto qp_out;
} }
ic->i_recv_hdrs = ib_dma_alloc_coherent(dev, ic->i_recv_hdrs = ib_dma_alloc_coherent(dev,
...@@ -514,7 +514,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn) ...@@ -514,7 +514,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
if (!ic->i_recv_hdrs) { if (!ic->i_recv_hdrs) {
ret = -ENOMEM; ret = -ENOMEM;
rdsdebug("ib_dma_alloc_coherent recv failed\n"); rdsdebug("ib_dma_alloc_coherent recv failed\n");
goto out; goto send_hdrs_dma_out;
} }
ic->i_ack = ib_dma_alloc_coherent(dev, sizeof(struct rds_header), ic->i_ack = ib_dma_alloc_coherent(dev, sizeof(struct rds_header),
...@@ -522,7 +522,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn) ...@@ -522,7 +522,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
if (!ic->i_ack) { if (!ic->i_ack) {
ret = -ENOMEM; ret = -ENOMEM;
rdsdebug("ib_dma_alloc_coherent ack failed\n"); rdsdebug("ib_dma_alloc_coherent ack failed\n");
goto out; goto recv_hdrs_dma_out;
} }
ic->i_sends = vzalloc_node(ic->i_send_ring.w_nr * sizeof(struct rds_ib_send_work), ic->i_sends = vzalloc_node(ic->i_send_ring.w_nr * sizeof(struct rds_ib_send_work),
...@@ -530,7 +530,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn) ...@@ -530,7 +530,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
if (!ic->i_sends) { if (!ic->i_sends) {
ret = -ENOMEM; ret = -ENOMEM;
rdsdebug("send allocation failed\n"); rdsdebug("send allocation failed\n");
goto out; goto ack_dma_out;
} }
ic->i_recvs = vzalloc_node(ic->i_recv_ring.w_nr * sizeof(struct rds_ib_recv_work), ic->i_recvs = vzalloc_node(ic->i_recv_ring.w_nr * sizeof(struct rds_ib_recv_work),
...@@ -538,7 +538,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn) ...@@ -538,7 +538,7 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
if (!ic->i_recvs) { if (!ic->i_recvs) {
ret = -ENOMEM; ret = -ENOMEM;
rdsdebug("recv allocation failed\n"); rdsdebug("recv allocation failed\n");
goto out; goto sends_out;
} }
rds_ib_recv_init_ack(ic); rds_ib_recv_init_ack(ic);
...@@ -546,8 +546,33 @@ static int rds_ib_setup_qp(struct rds_connection *conn) ...@@ -546,8 +546,33 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
rdsdebug("conn %p pd %p cq %p %p\n", conn, ic->i_pd, rdsdebug("conn %p pd %p cq %p %p\n", conn, ic->i_pd,
ic->i_send_cq, ic->i_recv_cq); ic->i_send_cq, ic->i_recv_cq);
out: return ret;
sends_out:
vfree(ic->i_sends);
ack_dma_out:
ib_dma_free_coherent(dev, sizeof(struct rds_header),
ic->i_ack, ic->i_ack_dma);
recv_hdrs_dma_out:
ib_dma_free_coherent(dev, ic->i_recv_ring.w_nr *
sizeof(struct rds_header),
ic->i_recv_hdrs, ic->i_recv_hdrs_dma);
send_hdrs_dma_out:
ib_dma_free_coherent(dev, ic->i_send_ring.w_nr *
sizeof(struct rds_header),
ic->i_send_hdrs, ic->i_send_hdrs_dma);
qp_out:
rdma_destroy_qp(ic->i_cm_id);
recv_cq_out:
if (!ib_destroy_cq(ic->i_recv_cq))
ic->i_recv_cq = NULL;
send_cq_out:
if (!ib_destroy_cq(ic->i_send_cq))
ic->i_send_cq = NULL;
rds_ibdev_out:
rds_ib_remove_conn(rds_ibdev, conn);
rds_ib_dev_put(rds_ibdev); rds_ib_dev_put(rds_ibdev);
return ret; return ret;
} }
......
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