Skip to content

Commit

Permalink
mm/slub: remove freelist_dereference()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Vlastimil Babka committed Jul 14, 2023
1 parent b06952c commit 1662b6c
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1662b6c

Please sign in to comment.