提交 c079c287 编写于 作者: E Emil Goode 提交者: Roland Dreier

RDMA/cxgb4: Fix error handling in create_qp()

The variable ret is assigned return values in a couple of places, but
its value is never returned.  This patch makes use of the ret variable
so that the caller get correct error codes returned.

The following changes are also introduced:

- The alloc_oc_sq function can return -ENOSYS or -ENOMEM so we want to
  get the return value from it.

- Change the label names to improve readability.
Signed-off-by: NEmil Goode <emilgoode@gmail.com>
Acked-by: NSteve Wise <swise@opengridcomputing.com>
Signed-off-by: NRoland Dreier <roland@purestorage.com>
上级 979570e0
...@@ -137,19 +137,25 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq, ...@@ -137,19 +137,25 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
return -ENOMEM; return -ENOMEM;
wq->rq.qid = c4iw_get_qpid(rdev, uctx); wq->rq.qid = c4iw_get_qpid(rdev, uctx);
if (!wq->rq.qid) if (!wq->rq.qid) {
goto err1; ret = -ENOMEM;
goto free_sq_qid;
}
if (!user) { if (!user) {
wq->sq.sw_sq = kzalloc(wq->sq.size * sizeof *wq->sq.sw_sq, wq->sq.sw_sq = kzalloc(wq->sq.size * sizeof *wq->sq.sw_sq,
GFP_KERNEL); GFP_KERNEL);
if (!wq->sq.sw_sq) if (!wq->sq.sw_sq) {
goto err2; ret = -ENOMEM;
goto free_rq_qid;
}
wq->rq.sw_rq = kzalloc(wq->rq.size * sizeof *wq->rq.sw_rq, wq->rq.sw_rq = kzalloc(wq->rq.size * sizeof *wq->rq.sw_rq,
GFP_KERNEL); GFP_KERNEL);
if (!wq->rq.sw_rq) if (!wq->rq.sw_rq) {
goto err3; ret = -ENOMEM;
goto free_sw_sq;
}
} }
/* /*
...@@ -157,15 +163,23 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq, ...@@ -157,15 +163,23 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
*/ */
wq->rq.rqt_size = roundup_pow_of_two(wq->rq.size); wq->rq.rqt_size = roundup_pow_of_two(wq->rq.size);
wq->rq.rqt_hwaddr = c4iw_rqtpool_alloc(rdev, wq->rq.rqt_size); wq->rq.rqt_hwaddr = c4iw_rqtpool_alloc(rdev, wq->rq.rqt_size);
if (!wq->rq.rqt_hwaddr) if (!wq->rq.rqt_hwaddr) {
goto err4; ret = -ENOMEM;
goto free_sw_rq;
}
if (user) { if (user) {
if (alloc_oc_sq(rdev, &wq->sq) && alloc_host_sq(rdev, &wq->sq)) ret = alloc_oc_sq(rdev, &wq->sq);
goto err5; if (ret)
goto free_hwaddr;
ret = alloc_host_sq(rdev, &wq->sq);
if (ret)
goto free_sq;
} else } else
if (alloc_host_sq(rdev, &wq->sq)) ret = alloc_host_sq(rdev, &wq->sq);
goto err5; if (ret)
goto free_hwaddr;
memset(wq->sq.queue, 0, wq->sq.memsize); memset(wq->sq.queue, 0, wq->sq.memsize);
dma_unmap_addr_set(&wq->sq, mapping, wq->sq.dma_addr); dma_unmap_addr_set(&wq->sq, mapping, wq->sq.dma_addr);
...@@ -173,7 +187,7 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq, ...@@ -173,7 +187,7 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
wq->rq.memsize, &(wq->rq.dma_addr), wq->rq.memsize, &(wq->rq.dma_addr),
GFP_KERNEL); GFP_KERNEL);
if (!wq->rq.queue) if (!wq->rq.queue)
goto err6; goto free_sq;
PDBG("%s sq base va 0x%p pa 0x%llx rq base va 0x%p pa 0x%llx\n", PDBG("%s sq base va 0x%p pa 0x%llx rq base va 0x%p pa 0x%llx\n",
__func__, wq->sq.queue, __func__, wq->sq.queue,
(unsigned long long)virt_to_phys(wq->sq.queue), (unsigned long long)virt_to_phys(wq->sq.queue),
...@@ -201,7 +215,7 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq, ...@@ -201,7 +215,7 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
skb = alloc_skb(wr_len, GFP_KERNEL); skb = alloc_skb(wr_len, GFP_KERNEL);
if (!skb) { if (!skb) {
ret = -ENOMEM; ret = -ENOMEM;
goto err7; goto free_dma;
} }
set_wr_txq(skb, CPL_PRIORITY_CONTROL, 0); set_wr_txq(skb, CPL_PRIORITY_CONTROL, 0);
...@@ -266,33 +280,33 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq, ...@@ -266,33 +280,33 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
ret = c4iw_ofld_send(rdev, skb); ret = c4iw_ofld_send(rdev, skb);
if (ret) if (ret)
goto err7; goto free_dma;
ret = c4iw_wait_for_reply(rdev, &wr_wait, 0, wq->sq.qid, __func__); ret = c4iw_wait_for_reply(rdev, &wr_wait, 0, wq->sq.qid, __func__);
if (ret) if (ret)
goto err7; goto free_dma;
PDBG("%s sqid 0x%x rqid 0x%x kdb 0x%p squdb 0x%llx rqudb 0x%llx\n", PDBG("%s sqid 0x%x rqid 0x%x kdb 0x%p squdb 0x%llx rqudb 0x%llx\n",
__func__, wq->sq.qid, wq->rq.qid, wq->db, __func__, wq->sq.qid, wq->rq.qid, wq->db,
(unsigned long long)wq->sq.udb, (unsigned long long)wq->rq.udb); (unsigned long long)wq->sq.udb, (unsigned long long)wq->rq.udb);
return 0; return 0;
err7: free_dma:
dma_free_coherent(&(rdev->lldi.pdev->dev), dma_free_coherent(&(rdev->lldi.pdev->dev),
wq->rq.memsize, wq->rq.queue, wq->rq.memsize, wq->rq.queue,
dma_unmap_addr(&wq->rq, mapping)); dma_unmap_addr(&wq->rq, mapping));
err6: free_sq:
dealloc_sq(rdev, &wq->sq); dealloc_sq(rdev, &wq->sq);
err5: free_hwaddr:
c4iw_rqtpool_free(rdev, wq->rq.rqt_hwaddr, wq->rq.rqt_size); c4iw_rqtpool_free(rdev, wq->rq.rqt_hwaddr, wq->rq.rqt_size);
err4: free_sw_rq:
kfree(wq->rq.sw_rq); kfree(wq->rq.sw_rq);
err3: free_sw_sq:
kfree(wq->sq.sw_sq); kfree(wq->sq.sw_sq);
err2: free_rq_qid:
c4iw_put_qpid(rdev, wq->rq.qid, uctx); c4iw_put_qpid(rdev, wq->rq.qid, uctx);
err1: free_sq_qid:
c4iw_put_qpid(rdev, wq->sq.qid, uctx); c4iw_put_qpid(rdev, wq->sq.qid, uctx);
return -ENOMEM; return ret;
} }
static int build_immd(struct t4_sq *sq, struct fw_ri_immd *immdp, static int build_immd(struct t4_sq *sq, struct fw_ri_immd *immdp,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册