@@ -4094,9 +4094,6 @@ static inline unsigned int calc_slab_order(unsigned int size,
unsigned int min_order = slub_min_order;
unsigned int order;
- if (order_objects(min_order, size) > MAX_OBJS_PER_PAGE)
- return get_order(size * MAX_OBJS_PER_PAGE) - 1;
-
for (order = max(min_order, (unsigned int)get_order(min_objects * size));
order <= max_order; order++) {
@@ -4457,9 +4454,14 @@ static int calculate_sizes(struct kmem_cache *s)
size = ALIGN(size, s->align);
s->size = size;
s->reciprocal_size = reciprocal_value(size);
- order = calculate_order(size);
- if ((int)order < 0)
+
+ if (order_objects(slub_min_order, size) > MAX_OBJS_PER_PAGE)
+ order = get_order(size * MAX_OBJS_PER_PAGE) - 1;
+ else
+ order = calculate_order(size);
+
+ if ((int)order < 0 || order > slub_max_order)
return 0;
s->allocflags = 0;