diff mbox

[10/16] ibacm: add locking around end point address arrays

Message ID 1395985810-23822-11-git-send-email-sean.hefty@intel.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Hefty, Sean March 28, 2014, 5:50 a.m. UTC
From: Ira Weiny <ira.weiny@intel.com>

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
 src/acm.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/src/acm.c b/src/acm.c
index c5da791..ebb48f4 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -92,7 +92,7 @@  enum acm_addr_preload {
 };
 
 /*
- * Nested locking order: dest -> ep, dest -> port
+ * Nested locking order: dest -> ep, dest -> port, port -> ep
  */
 struct acm_dest {
 	uint8_t                address[ACM_MAX_ADDRESS]; /* keep first */
@@ -1830,8 +1830,12 @@  acm_get_port_ep(struct acm_port *port, struct acm_ep_addr_data *data)
 		    (!data->info.path.pkey || (ntohs(data->info.path.pkey) == ep->pkey)))
 			return ep;
 
-		if (acm_addr_index(ep, data->info.addr, (uint8_t) data->type) >= 0)
+		lock_acquire(&ep->lock);
+		if (acm_addr_index(ep, data->info.addr, (uint8_t) data->type) >= 0) {
+			lock_release(&ep->lock);
 			return ep;
+		}
+		lock_release(&ep->lock);
 	}
 
 	return NULL;