Merge tag 'x86_cache_for_v5.10' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / mm / slab.c
index 3160dff..f658e86 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1632,6 +1632,10 @@ static void slab_destroy(struct kmem_cache *cachep, struct page *page)
                kmem_cache_free(cachep->freelist_cache, freelist);
 }
 
+/*
+ * Update the size of the caches before calling slabs_destroy as it may
+ * recursively call kfree.
+ */
 static void slabs_destroy(struct kmem_cache *cachep, struct list_head *list)
 {
        struct page *page, *n;
@@ -2153,8 +2157,8 @@ static void do_drain(void *arg)
        spin_lock(&n->list_lock);
        free_block(cachep, ac->entry, ac->avail, node, &list);
        spin_unlock(&n->list_lock);
-       slabs_destroy(cachep, &list);
        ac->avail = 0;
+       slabs_destroy(cachep, &list);
 }
 
 static void drain_cpu_caches(struct kmem_cache *cachep)
@@ -3402,9 +3406,9 @@ free_done:
        }
 #endif
        spin_unlock(&n->list_lock);
-       slabs_destroy(cachep, &list);
        ac->avail -= batchcount;
        memmove(ac->entry, &(ac->entry[batchcount]), sizeof(void *)*ac->avail);
+       slabs_destroy(cachep, &list);
 }
 
 /*