diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index 87cc678adc85..432151e52f3f 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -68,9 +68,11 @@ static inline unsigned int folio_batch_space(struct folio_batch *fbatch) * * Return: The number of slots still available. */ -static inline unsigned folio_batch_add(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); }