[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230711134623.12695-4-vbabka@suse.cz>
Date: Tue, 11 Jul 2023 15:46:25 +0200
From: Vlastimil Babka <vbabka@...e.cz>
To: Christoph Lameter <cl@...ux.com>,
David Rientjes <rientjes@...gle.com>,
Pekka Enberg <penberg@...nel.org>,
Joonsoo Kim <iamjoonsoo.kim@....com>
Cc: Hyeonggon Yoo <42.hyeyoo@...il.com>,
Roman Gushchin <roman.gushchin@...ux.dev>, linux-mm@...ck.org,
patches@...ts.linux.dev, linux-kernel@...r.kernel.org,
Matteo Rizzo <matteorizzo@...gle.com>,
Jann Horn <jannh@...gle.com>,
Andrey Konovalov <andreyknvl@...gle.com>,
Marco Elver <elver@...gle.com>,
Alexander Potapenko <glider@...gle.com>,
kasan-dev@...glegroups.com, Kees Cook <keescook@...omium.org>,
linux-hardening@...r.kernel.org, Vlastimil Babka <vbabka@...e.cz>
Subject: [PATCH 2/2] mm/slub: remove freelist_dereference()
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@...e.cz>
---
mm/slub.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/mm/slub.c b/mm/slub.c
index 07edad305512..c4556a5dab4b 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -397,18 +397,14 @@ 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)
{
- object = kasan_reset_tag(object);
- return freelist_dereference(s, (freeptr_t *)(object + s->offset));
+ unsigned long ptr_addr;
+ freeptr_t p;
+
+ ptr_addr = ((unsigned long)kasan_reset_tag(object)) + s->offset;
+ p = *(freeptr_t *)(ptr_addr);
+ return freelist_ptr_decode(s, p, ptr_addr);
}
#ifndef CONFIG_SLUB_TINY
--
2.41.0
Powered by blists - more mailing lists