From 3b9c69d67b9e444844d2ef6d3278804bb1b3ecb2 Mon Sep 17 00:00:00 2001
From: isaac <isaac>
Date: Tue, 12 Jun 2007 19:17:12 +0000
Subject: [PATCH] -   should init kptllnd_data.kptl_idle_txs before calling
 kptllnd_shutdown. -   should init kptllnd_data.kptl_ptlid2str_lock before
 calling kptllnd_ptlid2str.

---
 lnet/ChangeLog             |  6 ++++++
 lnet/klnds/ptllnd/ptllnd.c | 39 +++++++++++++++++++-------------------
 2 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/lnet/ChangeLog b/lnet/ChangeLog
index 6ebdfea25d..15e76fb505 100644
--- a/lnet/ChangeLog
+++ b/lnet/ChangeLog
@@ -30,6 +30,12 @@
 	ptllnd    - Portals 3.3 / UNICOS/lc 1.5.x, 2.0.x
        * bug fixes
 	
+Severity   : minor
+Frequency  : rare
+Description: Ptllnd didn't init kptllnd_data.kptl_idle_txs before it could be
+	     possibly accessed in kptllnd_shutdown. Ptllnd should init 
+	     kptllnd_data.kptl_ptlid2str_lock before calling kptllnd_ptlid2str.
+
 Severity   : normal
 Frequency  : rare
 Description: gmlnd ignored some transmit errors when finalizing lnet messages.
diff --git a/lnet/klnds/ptllnd/ptllnd.c b/lnet/klnds/ptllnd/ptllnd.c
index fd707f38a6..f020fac693 100755
--- a/lnet/klnds/ptllnd/ptllnd.c
+++ b/lnet/klnds/ptllnd/ptllnd.c
@@ -471,7 +471,7 @@ kptllnd_startup (lnet_ni_t *ni)
         }
 
         if (*kptllnd_tunables.kptl_max_procs_per_node < 1) {
-                CERROR("max_procs_per_node must be > 1\n");
+                CERROR("max_procs_per_node must be >= 1\n");
                 return -EINVAL;
         }
 
@@ -490,6 +490,25 @@ kptllnd_startup (lnet_ni_t *ni)
         kptllnd_data.kptl_eqh = PTL_INVALID_HANDLE;
         kptllnd_data.kptl_nih = PTL_INVALID_HANDLE;
 
+        /*
+         * Setup the sched locks/lists/waitq
+         */
+        spin_lock_init(&kptllnd_data.kptl_sched_lock);
+        init_waitqueue_head(&kptllnd_data.kptl_sched_waitq);
+        INIT_LIST_HEAD(&kptllnd_data.kptl_sched_txq);
+        INIT_LIST_HEAD(&kptllnd_data.kptl_sched_rxq);
+        INIT_LIST_HEAD(&kptllnd_data.kptl_sched_rxbq);
+
+        /* init kptl_ptlid2str_lock before any call to kptllnd_ptlid2str */
+        spin_lock_init(&kptllnd_data.kptl_ptlid2str_lock);
+
+        /*
+         * Setup the tx locks/lists
+         */
+        spin_lock_init(&kptllnd_data.kptl_tx_lock);
+        INIT_LIST_HEAD(&kptllnd_data.kptl_idle_txs);
+        atomic_set(&kptllnd_data.kptl_ntx, 0);
+
         /*
          * Uptick the module reference count
          */
@@ -585,22 +604,6 @@ kptllnd_startup (lnet_ni_t *ni)
                                         tv.tv_usec;
         CDEBUG(D_NET, "Incarnation="LPX64"\n", kptllnd_data.kptl_incarnation);
 
-        /*
-         * Setup the sched locks/lists/waitq
-         */
-        spin_lock_init(&kptllnd_data.kptl_sched_lock);
-        init_waitqueue_head(&kptllnd_data.kptl_sched_waitq);
-        INIT_LIST_HEAD(&kptllnd_data.kptl_sched_txq);
-        INIT_LIST_HEAD(&kptllnd_data.kptl_sched_rxq);
-        INIT_LIST_HEAD(&kptllnd_data.kptl_sched_rxbq);
-
-        /*
-         * Setup the tx locks/lists
-         */
-        spin_lock_init(&kptllnd_data.kptl_tx_lock);
-        INIT_LIST_HEAD(&kptllnd_data.kptl_idle_txs);
-        atomic_set(&kptllnd_data.kptl_ntx, 0);
-
         /*
          * Allocate and setup the peer hash table
          */
@@ -609,8 +612,6 @@ kptllnd_startup (lnet_ni_t *ni)
         INIT_LIST_HEAD(&kptllnd_data.kptl_closing_peers);
         INIT_LIST_HEAD(&kptllnd_data.kptl_zombie_peers);
 
-        spin_lock_init(&kptllnd_data.kptl_ptlid2str_lock);
-
         kptllnd_data.kptl_peer_hash_size =
                 *kptllnd_tunables.kptl_peer_hash_table_size;
         LIBCFS_ALLOC(kptllnd_data.kptl_peers,
-- 
GitLab