From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Joe Jin <joe.jin@oracle.com>,
Junxiao Bi <junxiao.bi@oracle.com>,
Guanglei Li <guanglei.li@oracle.com>,
Zhu Yanjun <yanjun.zhu@oracle.com>,
Santosh Shilimkar <santosh.shilimkar@oracle.com>,
"David S. Miller" <davem@davemloft.net>,
Sasha Levin <alexander.levin@verizon.com>
Subject: [PATCH 3.18 26/35] rds: ib: add error handle
Date: Fri, 6 Oct 2017 11:25:06 +0200 [thread overview]
Message-ID: <20171006092403.851771642@linuxfoundation.org> (raw)
In-Reply-To: <20171006092402.810400570@linuxfoundation.org>
3.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhu Yanjun <yanjun.zhu@oracle.com>
[ Upstream commit 3b12f73a5c2977153f28a224392fd4729b50d1dc ]
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: Junxiao Bi <junxiao.bi@oracle.com>
Reviewed-by: Guanglei Li <guanglei.li@oracle.com>
Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/rds/ib_cm.c | 47 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 36 insertions(+), 11 deletions(-)
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -298,7 +298,7 @@ static int rds_ib_setup_qp(struct rds_co
ret = PTR_ERR(ic->i_send_cq);
ic->i_send_cq = NULL;
rdsdebug("ib_create_cq send failed: %d\n", ret);
- goto out;
+ goto rds_ibdev_out;
}
ic->i_recv_cq = ib_create_cq(dev, rds_ib_recv_cq_comp_handler,
@@ -308,19 +308,19 @@ static int rds_ib_setup_qp(struct rds_co
ret = PTR_ERR(ic->i_recv_cq);
ic->i_recv_cq = NULL;
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);
if (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);
if (ret) {
rdsdebug("ib_req_notify_cq recv failed: %d\n", ret);
- goto out;
+ goto recv_cq_out;
}
/* XXX negotiate max send/recv with remote? */
@@ -344,7 +344,7 @@ static int rds_ib_setup_qp(struct rds_co
ret = rdma_create_qp(ic->i_cm_id, ic->i_pd, &attr);
if (ret) {
rdsdebug("rdma_create_qp failed: %d\n", ret);
- goto out;
+ goto recv_cq_out;
}
ic->i_send_hdrs = ib_dma_alloc_coherent(dev,
@@ -354,7 +354,7 @@ static int rds_ib_setup_qp(struct rds_co
if (!ic->i_send_hdrs) {
ret = -ENOMEM;
rdsdebug("ib_dma_alloc_coherent send failed\n");
- goto out;
+ goto qp_out;
}
ic->i_recv_hdrs = ib_dma_alloc_coherent(dev,
@@ -364,7 +364,7 @@ static int rds_ib_setup_qp(struct rds_co
if (!ic->i_recv_hdrs) {
ret = -ENOMEM;
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),
@@ -372,7 +372,7 @@ static int rds_ib_setup_qp(struct rds_co
if (!ic->i_ack) {
ret = -ENOMEM;
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),
@@ -380,7 +380,7 @@ static int rds_ib_setup_qp(struct rds_co
if (!ic->i_sends) {
ret = -ENOMEM;
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),
@@ -388,7 +388,7 @@ static int rds_ib_setup_qp(struct rds_co
if (!ic->i_recvs) {
ret = -ENOMEM;
rdsdebug("recv allocation failed\n");
- goto out;
+ goto sends_out;
}
rds_ib_recv_init_ack(ic);
@@ -396,8 +396,33 @@ static int rds_ib_setup_qp(struct rds_co
rdsdebug("conn %p pd %p mr %p cq %p %p\n", conn, ic->i_pd, ic->i_mr,
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);
+
return ret;
}
next prev parent reply other threads:[~2017-10-06 9:26 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-06 9:24 [PATCH 3.18 00/35] 3.18.74-stable review Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 01/35] drm: bridge: add DT bindings for TI ths8135 Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 02/35] RDS: RDMA: Fix the composite message user notification Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 03/35] MIPS: Ensure bss section ends on a long-aligned address Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 04/35] MIPS: kexec: Do not reserve invalid crashkernel memory on boot Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 06/35] hwmon: (gl520sm) Fix overflows and crash seen when writing into limit attributes Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 07/35] ARM: 8635/1: nommu: allow enabling REMAP_VECTORS_TO_RAM Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 08/35] tty: goldfish: Fix a parameter of a call to free_irq Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 09/35] IB/ipoib: Fix deadlock over vlan_mutex Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 10/35] IB/ipoib: rtnl_unlock can not come after free_netdev Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 11/35] IB/ipoib: Replace list_del of the neigh->list with list_del_init Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 12/35] USB: serial: mos7720: fix control-message error handling Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 13/35] USB: serial: mos7840: " Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 14/35] pinctrl: mvebu: Use seq_puts() in mvebu_pinconf_group_dbg_show() Greg Kroah-Hartman
2017-10-06 9:32 ` Joe Perches
2017-10-06 9:42 ` Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 15/35] partitions/efi: Fix integer overflow in GPT size calculation Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 16/35] audit: log 32-bit socketcalls Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 17/35] net: core: Prevent from dereferencing null pointer when releasing SKB Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 18/35] net/packet: check length in getsockopt() called with PACKET_HDRLEN Greg Kroah-Hartman
2017-10-06 9:24 ` [PATCH 3.18 19/35] team: fix memory leaks Greg Kroah-Hartman
2017-10-06 9:25 ` [PATCH 3.18 21/35] mmc: sdio: fix alignment issue in struct sdio_func Greg Kroah-Hartman
2017-10-06 9:25 ` [PATCH 3.18 22/35] netfilter: invoke synchronize_rcu after set the _hook_ to NULL Greg Kroah-Hartman
2017-10-06 9:25 ` [PATCH 3.18 23/35] [media] exynos-gsc: Do not swap cb/cr for semi planar formats Greg Kroah-Hartman
2017-10-06 9:25 ` [PATCH 3.18 24/35] netfilter: nfnl_cthelper: fix incorrect helper->expect_class_max Greg Kroah-Hartman
2017-10-06 9:25 ` [PATCH 3.18 25/35] parisc: perf: Fix potential NULL pointer dereference Greg Kroah-Hartman
2017-10-06 9:25 ` Greg Kroah-Hartman [this message]
2017-10-06 9:25 ` [PATCH 3.18 27/35] md/raid10: submit bio directly to replacement disk Greg Kroah-Hartman
2017-10-06 9:25 ` [PATCH 3.18 28/35] xfs: remove kmem_zalloc_greedy Greg Kroah-Hartman
2017-10-06 9:25 ` [PATCH 3.18 29/35] libata: transport: Remove circular dependency at free time Greg Kroah-Hartman
2017-10-06 9:25 ` [PATCH 3.18 30/35] IB/qib: fix false-postive maybe-uninitialized warning Greg Kroah-Hartman
2017-10-06 9:25 ` [PATCH 3.18 31/35] ALSA: au88x0: avoid theoretical uninitialized access Greg Kroah-Hartman
2017-10-06 9:25 ` [PATCH 3.18 32/35] [media] ttpci: address stringop overflow warning Greg Kroah-Hartman
2017-10-06 9:25 ` [PATCH 3.18 33/35] staging: nvec: remove duplicated const Greg Kroah-Hartman
2017-10-06 9:25 ` [PATCH 3.18 34/35] crypto: algif_skcipher - Load TX SG list after waiting Greg Kroah-Hartman
2017-10-06 9:25 ` [PATCH 3.18 35/35] mpi: Fix NULL ptr dereference in mpi_powm() [ver #3] Greg Kroah-Hartman
2017-10-06 14:03 ` [PATCH 3.18 00/35] 3.18.74-stable review Guenter Roeck
2017-10-07 9:38 ` Greg Kroah-Hartman
2017-10-06 17:30 ` Shuah Khan
2017-10-07 9:04 ` Greg Kroah-Hartman
2017-10-07 9:40 ` Greg Kroah-Hartman
2017-10-07 14:43 ` Guenter Roeck
2017-10-08 7:20 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171006092403.851771642@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=alexander.levin@verizon.com \
--cc=davem@davemloft.net \
--cc=guanglei.li@oracle.com \
--cc=joe.jin@oracle.com \
--cc=junxiao.bi@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=santosh.shilimkar@oracle.com \
--cc=stable@vger.kernel.org \
--cc=yanjun.zhu@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).