aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/infiniband/core/cma.c23
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;
1780err: 1781err2:
1782 if (!cma_any_addr(addr)) {
1783 mutex_lock(&lock);
1784 cma_detach_from_dev(id_priv);
1785 mutex_unlock(&lock);
1786 }
1787err1:
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}