diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h
index 1e7a3c1527..e7e09e48fc 100644
--- a/lib/mempool/rte_mempool.h
+++ b/lib/mempool/rte_mempool.h
@@ -1344,31 +1344,41 @@ rte_mempool_do_generic_put(struct rte_mempool *mp, void
* const *obj_table,
if (unlikely(cache == NULL || n > RTE_MEMPOOL_CACHE_MAX_SIZE))
goto ring_enqueue;
- cache_objs = &cache->objs[cache->len];
+ /* If the request itself is too big for the cache */
+ if (unlikely(n > cache->flushthresh))
+ goto ring_enqueue;
n is checked twice above and it is not actually required.
Just the later check is required.
Check vs RTE_MEMPOOL_CACHE_MAX_SIZE was required to ensure
that we do not overflow cache objects since we copied
to cache before flushing, but it is not the case now.
We never cross flush threshold now.
I'll send v5 were I split the most questionable part into
a separate patch at the end.