components/openvswitch/patches/07-ovsthread_key_destruct-fix.patch
author Chad Mynhier <chad.mynhier@oracle.com>
Wed, 12 Oct 2016 11:24:25 -0700
changeset 7095 6469e6424607
parent 6018 b5072b523988
permissions -rw-r--r--
24811276 Fix 64-bit Python builds so pstack(1) will work

This patch fixes a bug in ovsthread_key_destruct__.

This patch has not been proposed upstream but will be proposed for 2.5.

diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c
index 529756f..86a3fa4 100644
--- a/lib/ovs-thread.c
+++ b/lib/ovs-thread.c
@@ -28,6 +28,10 @@
 #include "socket-util.h"
 #include "util.h"
 
+#ifdef __sun
+#include <util-solaris.h>
+#endif
+
 #ifdef __CHECKER__
 /* Omit the definitions in this file because they are somewhat difficult to
  * write without prompting "sparse" complaints, without ugliness or
@@ -476,6 +480,13 @@ ovs_thread_stats_next_bucket(const struct ovsthread_stats *stats, size_t i)
     return i;
 }
 
+#ifdef __sun
+static void
+parse_cpuinfo(long int *n_cores)
+{
+    solaris_parse_cpuinfo(n_cores);
+}
+#else
 
 /* Parses /proc/cpuinfo for the total number of physical cores on this system
  * across all CPU packages, not counting hyper-threads.
@@ -531,6 +542,7 @@ parse_cpuinfo(long int *n_cores)
 
     *n_cores = cores;
 }
+#endif
 
 /* Returns the total number of cores on this system, or 0 if the number cannot
  * be determined.
@@ -641,8 +653,10 @@ ovsthread_key_destruct__(void *slots_)
     n = n_keys;
     ovs_mutex_unlock(&key_mutex);
 
-    for (i = 0; i < n / L2_SIZE; i++) {
-        free(slots->p1[i]);
+    if (n > 0) {
+        for (i = 0; i <= (n - 1) / L2_SIZE; i++) {
+            free(slots->p1[i]);
+         }
     }
     free(slots);
 }