diff mbox

[opensm] osm_trap_rcv.c: Fix locking in aging callback

Message ID 521620AA.5030906@dev.mellanox.co.il (mailing list archive)
State Accepted
Delegated to: Hal Rosenstock
Headers show

Commit Message

Hal Rosenstock Aug. 22, 2013, 2:31 p.m. UTC
From: Alex Netes <alexne@mellanox.com>

Callback execution should be under read lock as it accesses global data.

Signed-off-by: Alex Netes <alexne@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
---
 opensm/osm_trap_rcv.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/opensm/osm_trap_rcv.c b/opensm/osm_trap_rcv.c
index 4e59a17..6a7936d 100644
--- a/opensm/osm_trap_rcv.c
+++ b/opensm/osm_trap_rcv.c
@@ -115,6 +115,8 @@  static uint64_t aging_tracker_callback(IN uint64_t key, IN uint32_t num_regs,
 	lid = (ib_net16_t) ((key & 0x0000FFFF00000000ULL) >> 32);
 	port_num = (uint8_t) ((key & 0x00FF000000000000ULL) >> 48);
 
+	CL_PLOCK_ACQUIRE(sm->p_lock);
+
 	p_physp = get_physp_by_lid_and_num(sm, lid, port_num);
 	if (!p_physp) {
 		OSM_LOG(sm->p_log, OSM_LOG_VERBOSE,
@@ -140,5 +142,6 @@  static uint64_t aging_tracker_callback(IN uint64_t key, IN uint32_t num_regs,
 	}
 
+	CL_PLOCK_RELEASE(sm->p_lock);
 	OSM_LOG_EXIT(sm->p_log);
 
 	/* We want to remove the event from the tracker - so