summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2020-06-26 13:07:53 -0700
committerStephen Rothwell <sfr@canb.auug.org.au>2020-06-29 18:08:04 +1000
commit8a893998b5943be5dfd104f313ebbeb6d14fcf55 (patch)
treeafac3feff56cd6ad7169ab77a05e15018600a9e2
parent395b5751f368c4857d46856b5a7311b123b1a47c (diff)
downloadlinux-8a893998b5943be5dfd104f313ebbeb6d14fcf55.tar.gz
linux-8a893998b5943be5dfd104f313ebbeb6d14fcf55.tar.xz
slab: Fix misplaced __free_one()
The implementation of __free_one() was accidentally placed inside a CONFIG_NUMA #ifdef. Move it above. Reported-by: Randy Dunlap <rdunlap@infradead.org> Link: https://lore.kernel.org/lkml/7ff248c7-d447-340c-a8e2-8c02972aca70@infradead.org Signed-off-by: Kees Cook <keescook@chromium.org>
-rw-r--r--mm/slab.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/mm/slab.c b/mm/slab.c
index 421c4b9e9615..ac7a223d9ac3 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -588,6 +588,16 @@ static int transfer_objects(struct array_cache *to,
return nr;
}
+/* &alien->lock must be held by alien callers. */
+static __always_inline void __free_one(struct array_cache *ac, void *objp)
+{
+ /* Avoid trivial double-free. */
+ if (IS_ENABLED(CONFIG_SLAB_FREELIST_HARDENED) &&
+ WARN_ON_ONCE(ac->avail > 0 && ac->entry[ac->avail - 1] == objp))
+ return;
+ ac->entry[ac->avail++] = objp;
+}
+
#ifndef CONFIG_NUMA
#define drain_alien_cache(cachep, alien) do { } while (0)
@@ -749,16 +759,6 @@ static void drain_alien_cache(struct kmem_cache *cachep,
}
}
-/* &alien->lock must be held by alien callers. */
-static __always_inline void __free_one(struct array_cache *ac, void *objp)
-{
- /* Avoid trivial double-free. */
- if (IS_ENABLED(CONFIG_SLAB_FREELIST_HARDENED) &&
- WARN_ON_ONCE(ac->avail > 0 && ac->entry[ac->avail - 1] == objp))
- return;
- ac->entry[ac->avail++] = objp;
-}
-
static int __cache_free_alien(struct kmem_cache *cachep, void *objp,
int node, int page_node)
{