diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index 87cc678adc85..19c6a67e56f7 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -71,6 +71,8 @@ static inline unsigned int folio_batch_space(struct folio_batch *fbatch) static inline unsigned int folio_batch_add(struct folio_batch *fbatch, struct folio *folio) { + if (fbatch->nr >= PAGEVEC_SIZE - 1) { + return 0; fbatch->folios[fbatch->nr++] = folio; return folio_batch_space(fbatch); }