tree.h cache-instrumented macros were invalidating NULL pointers in some cases
authorJustin Sobota <jsobota@ti.com>
Wed, 8 Jul 2015 20:46:12 +0000 (16:46 -0400)
committerJustin Sobota <jsobota@ti.com>
Wed, 8 Jul 2015 20:46:12 +0000 (16:46 -0400)
src/rm.c
util/tree.h

index 6caf08b85a7abbfffbf3dad0d7b9e353aa468853..d95d87eca17d4eeb22025b3032c2f57351cbafa5 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -1691,7 +1691,7 @@ Rm_Handle Rm_init(const Rm_InitCfg *initCfg, int32_t *result)
         goto errorExit;
     }
 
         goto errorExit;
     }
 
-    if (initCfg->instType == Rm_instType_SHARED_SERVER) {
+    if (rmInst->instType == Rm_instType_SHARED_SERVER) {
         /* Writeback instance and trees for other cores */
         rmPolicyValidInstTreeWb(rmInst->validInstTree);
         rmAllocatorTreeWb(rmInst->allocatorTree);
         /* Writeback instance and trees for other cores */
         rmPolicyValidInstTreeWb(rmInst->validInstTree);
         rmAllocatorTreeWb(rmInst->allocatorTree);
@@ -1701,7 +1701,7 @@ Rm_Handle Rm_init(const Rm_InitCfg *initCfg, int32_t *result)
         /* Create the instance's task blocking mechanism */
         rmInst->blockHandle = Rm_osalTaskBlockCreate();
     }
         /* Create the instance's task blocking mechanism */
         rmInst->blockHandle = Rm_osalTaskBlockCreate();
     }
-    /* else: fall through */
+    /* else: just return handle */
 
     return((Rm_Handle)rmInst);
 
 
     return((Rm_Handle)rmInst);
 
index 8ada42d2f9c1082b1676b652a9d9233583ef0fbf..c2713901ce45f38016945aa455b43fb6f0206a68 100644 (file)
@@ -719,31 +719,33 @@ name##_RB_MINMAX(struct name *head, int val)                              \
                        tmp = RB_RIGHT(tmp, field);                     \
        }                                                               \
        return (parent);                                                \
                        tmp = RB_RIGHT(tmp, field);                     \
        }                                                               \
        return (parent);                                                \
-}                                   \
-                                                                               \
+}                                                                                      \
+                                                                       \
 /* ARGSUSED */                                                         \
 attr struct type *                                                     \
 name##_RB_NEXT_CACHED(struct type *elm)                                        \
 {                                                                      \
 /* ARGSUSED */                                                         \
 attr struct type *                                                     \
 name##_RB_NEXT_CACHED(struct type *elm)                                        \
 {                                                                      \
-    inv(elm);                               \
+       inv(elm);                                                                       \
        if (RB_RIGHT(elm, field)) {                                     \
                elm = RB_RIGHT(elm, field);                             \
        if (RB_RIGHT(elm, field)) {                                     \
                elm = RB_RIGHT(elm, field);                             \
-               inv(elm);                               \
+               inv(elm);                                                               \
                while (RB_LEFT(elm, field)) {                           \
                        elm = RB_LEFT(elm, field);                      \
                while (RB_LEFT(elm, field)) {                           \
                        elm = RB_LEFT(elm, field);                      \
-                       inv(elm);                               \
-               }                                       \
+                       inv(elm);                                                       \
+               }                                                                               \
        } else {                                                        \
        } else {                                                        \
-           inv(RB_PARENT(elm, field));            \
+               if (RB_PARENT(elm, field))              \
+                       inv(RB_PARENT(elm, field));     \
                if (RB_PARENT(elm, field) &&                            \
                if (RB_PARENT(elm, field) &&                            \
-                   (elm == RB_LEFT(RB_PARENT(elm, field), field)))     \
+                       (elm == RB_LEFT(RB_PARENT(elm, field), field))) \
                        elm = RB_PARENT(elm, field);                    \
                else {                                                  \
                        while (RB_PARENT(elm, field) &&                 \
                        elm = RB_PARENT(elm, field);                    \
                else {                                                  \
                        while (RB_PARENT(elm, field) &&                 \
-                           (elm == RB_RIGHT(RB_PARENT(elm, field), field))) {\
+                               (elm == RB_RIGHT(RB_PARENT(elm, field), field))) {\
                                elm = RB_PARENT(elm, field);            \
                                elm = RB_PARENT(elm, field);            \
-                               inv(RB_PARENT(elm, field));                      \
-                       }                                       \
+                               if (RB_PARENT(elm, field))                      \
+                                       inv(RB_PARENT(elm, field));             \
+                       }                                                                               \
                        elm = RB_PARENT(elm, field);                    \
                }                                                       \
        }                                                               \
                        elm = RB_PARENT(elm, field);                    \
                }                                                       \
        }                                                               \
@@ -756,8 +758,8 @@ name##_RB_MINMAX_CACHED(struct name *head, int val)                         \
        struct type *tmp = RB_ROOT(head);                               \
        struct type *parent = NULL;                                     \
        while (tmp) {                                                   \
        struct type *tmp = RB_ROOT(head);                               \
        struct type *parent = NULL;                                     \
        while (tmp) {                                                   \
+               inv(tmp);                                                       \
                parent = tmp;                                           \
                parent = tmp;                                           \
-               inv(tmp);                               \
                if (val < 0)                                            \
                        tmp = RB_LEFT(tmp, field);                      \
                else                                                    \
                if (val < 0)                                            \
                        tmp = RB_LEFT(tmp, field);                      \
                else                                                    \