diff options
author | Krishna Kumar <krkumar2@in.ibm.com> | 2006-10-24 16:22:28 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-10-30 23:52:51 -0500 |
commit | 255d0c14b3757e8bd85add874e4dca4c3621b39e (patch) | |
tree | 7b12b21a99da6dfba8097558d270b9c9e84dfd9f /drivers | |
parent | 2e7a7426282bfa2d7dff6eddc5485af8c79a68f3 (diff) |
RDMA/cma: rdma_bind_addr() leaks a cma_dev reference count
rdma_bind_addr() leaks a cma_dev reference count in failure case.
Signed-off-by: Krishna Kumar <krkumar2@in.ibm.com>
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/core/cma.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 9ae4f3a67c70..d8ca3c1368b5 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c | |||
@@ -1762,22 +1762,29 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr) | |||
1762 | 1762 | ||
1763 | if (!cma_any_addr(addr)) { | 1763 | if (!cma_any_addr(addr)) { |
1764 | ret = rdma_translate_ip(addr, &id->route.addr.dev_addr); | 1764 | ret = rdma_translate_ip(addr, &id->route.addr.dev_addr); |
1765 | if (!ret) { | ||
1766 | mutex_lock(&lock); | ||
1767 | ret = cma_acquire_dev(id_priv); | ||
1768 | mutex_unlock(&lock); | ||
1769 | } | ||
1770 | if (ret) | 1765 | if (ret) |
1771 | goto err; | 1766 | goto err1; |
1767 | |||
1768 | mutex_lock(&lock); | ||
1769 | ret = cma_acquire_dev(id_priv); | ||
1770 | mutex_unlock(&lock); | ||
1771 | if (ret) | ||
1772 | goto err1; | ||
1772 | } | 1773 | } |
1773 | 1774 | ||
1774 | memcpy(&id->route.addr.src_addr, addr, ip_addr_size(addr)); | 1775 | memcpy(&id->route.addr.src_addr, addr, ip_addr_size(addr)); |
1775 | ret = cma_get_port(id_priv); | 1776 | ret = cma_get_port(id_priv); |
1776 | if (ret) | 1777 | if (ret) |
1777 | goto err; | 1778 | goto err2; |
1778 | 1779 | ||
1779 | return 0; | 1780 | return 0; |
1780 | err: | 1781 | err2: |
1782 | if (!cma_any_addr(addr)) { | ||
1783 | mutex_lock(&lock); | ||
1784 | cma_detach_from_dev(id_priv); | ||
1785 | mutex_unlock(&lock); | ||
1786 | } | ||
1787 | err1: | ||
1781 | cma_comp_exch(id_priv, CMA_ADDR_BOUND, CMA_IDLE); | 1788 | cma_comp_exch(id_priv, CMA_ADDR_BOUND, CMA_IDLE); |
1782 | return ret; | 1789 | return ret; |
1783 | } | 1790 | } |