kbuild: Disable -Wpointer-to-enum-cast
[linux-2.6-microblaze.git] / lib / stackdepot.c
index ed717dd..81c69c0 100644 (file)
@@ -83,15 +83,19 @@ static bool init_stack_slab(void **prealloc)
                return true;
        if (stack_slabs[depot_index] == NULL) {
                stack_slabs[depot_index] = *prealloc;
+               *prealloc = NULL;
        } else {
-               stack_slabs[depot_index + 1] = *prealloc;
+               /* If this is the last depot slab, do not touch the next one. */
+               if (depot_index + 1 < STACK_ALLOC_MAX_SLABS) {
+                       stack_slabs[depot_index + 1] = *prealloc;
+                       *prealloc = NULL;
+               }
                /*
                 * This smp_store_release pairs with smp_load_acquire() from
                 * |next_slab_inited| above and in stack_depot_save().
                 */
                smp_store_release(&next_slab_inited, 1);
        }
-       *prealloc = NULL;
        return true;
 }