summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--mm/slub.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/mm/slub.c b/mm/slub.c
index bc949e3428c9..3098e0cf2899 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3581,6 +3581,13 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
 		 */
 		s->offset = size;
 		size += sizeof(void *);
+	} else if (size > sizeof(void *)) {
+		/*
+		 * Store freelist pointer near middle of object to keep
+		 * it away from the edges of the object to avoid small
+		 * sized over/underflows from neighboring allocations.
+		 */
+		s->offset = ALIGN(size / 2, sizeof(void *));
 	}
 
 #ifdef CONFIG_SLUB_DEBUG