diff mbox

[opensm] osm_opensm.c: Fix race condition between traps handling and SA shutdown

Message ID 556F23AE.9000608@dev.mellanox.co.il (mailing list archive)
State Accepted
Delegated to: Hal Rosenstock
Headers show

Commit Message

Hal Rosenstock June 3, 2015, 3:56 p.m. UTC
From: Daniel Klein <danielk@mellanox.com>
Date: Mon, 11 May 2015 10:36:46 +0300

Bug description:
When OpenSM handles traps during SA shutdown, it might append these
traps to p_subn->rcvd_traps_list after the list is flushed.
As a result, the memory allocated for the list elements is not released.

With this change, during shutdown process OpenSM shuts down SM before
shutting down the SA, in order to avoid processing traps during SA
shutdown.

Signed-off-by: Daniel Klein <danielk@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
---
 opensm/osm_opensm.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/opensm/osm_opensm.c b/opensm/osm_opensm.c
index a64a419..1d60e34 100644
--- a/opensm/osm_opensm.c
+++ b/opensm/osm_opensm.c
@@ -113,17 +113,17 @@  void osm_opensm_destroy(IN osm_opensm_t * p_osm)
 
 	osm_congestion_control_shutdown(&p_osm->cc);
 
-	/* shut down the SA
-	 * - unbind from QP1 messages
-	 */
-	osm_sa_shutdown(&p_osm->sa);
-
 	/* shut down the SM
 	 * - make sure the SM sweeper thread exited
 	 * - unbind from QP0 messages
 	 */
 	osm_sm_shutdown(&p_osm->sm);
 
+	/* shut down the SA
+	 * - unbind from QP1 messages
+	 */
+	osm_sa_shutdown(&p_osm->sa);
+
 	/* cleanup all messages on VL15 fifo that were not sent yet */
 	osm_vl15_shutdown(&p_osm->vl15, &p_osm->mad_pool);