diff --git a/mm/slab.c b/mm/slab.c index 8b71a9c3daa4a0b522451cbac2807f5fb3a424ba..21b2aef25254c191916e900b0913d03fa795b8bf 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -2990,6 +2990,14 @@ static void *cache_alloc_refill(struct kmem_cache *cachep, gfp_t flags) slabp = list_entry(entry, struct slab, list); check_slabp(cachep, slabp); check_spinlock_acquired(cachep); + + /* + * The slab was either on partial or free list so + * there must be at least one object available for + * allocation. + */ + BUG_ON(slabp->inuse < 0 || slabp->inuse >= cachep->num); + while (slabp->inuse < cachep->num && batchcount--) { STATS_INC_ALLOCED(cachep); STATS_INC_ACTIVE(cachep);