mm/slub: remove freelist_dereference()
authorVlastimil Babka <vbabka@suse.cz>
Tue, 11 Jul 2023 13:35:33 +0000 (15:35 +0200)
committerVlastimil Babka <vbabka@suse.cz>
Fri, 14 Jul 2023 07:57:21 +0000 (09:57 +0200)
freelist_dereference() is a one-liner only used from get_freepointer().
Remove it and make get_freepointer() call freelist_ptr_decode()
directly to make the code easier to follow.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Kees Cook <keescook@chromium.org>
mm/slub.c

index 07edad305512fdbf329c05370f7fcea8df1b0468..f7940048138c5a1c665673fa8a75df9c7115fa06 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -397,18 +397,15 @@ static inline void *freelist_ptr_decode(const struct kmem_cache *s,
        return decoded;
 }
 
-/* Returns the freelist pointer recorded at location ptr_addr. */
-static inline void *freelist_dereference(const struct kmem_cache *s,
-                                        void *ptr_addr)
-{
-       return freelist_ptr_decode(s, *(freeptr_t *)(ptr_addr),
-                           (unsigned long)ptr_addr);
-}
-
 static inline void *get_freepointer(struct kmem_cache *s, void *object)
 {
+       unsigned long ptr_addr;
+       freeptr_t p;
+
        object = kasan_reset_tag(object);
-       return freelist_dereference(s, (freeptr_t *)(object + s->offset));
+       ptr_addr = (unsigned long)object + s->offset;
+       p = *(freeptr_t *)(ptr_addr);
+       return freelist_ptr_decode(s, p, ptr_addr);
 }
 
 #ifndef CONFIG_SLUB_TINY