diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index 87cc678adc85..bf8d12533279 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -69,10 +69,12 @@ 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, - struct folio *folio) + struct folio *folio) { - fbatch->folios[fbatch->nr++] = folio; - return folio_batch_space(fbatch); + if (folio_batch_space(fbatch)) + fbatch->folios[fbatch->nr++] = folio; + + return folio_batch_space(fbatch); } void __folio_batch_release(struct folio_batch *pvec);