# Re: \[PATCH v14 079/138\] mm/filemap: Add readahead\_folio()

- From: David Howells \<dhowells@redhat.com\>
- Date: 2021-08-11 12:30:49 
- List: linux-mm
- Page: https://ratatoskr.run/linux-mm/2021/08/212098
- Thread: https://ratatoskr.run/linux-mm/2021/07/209943/t/5.md

```text
Matthew Wilcox (Oracle) [ref] wrote:

> +/**
> + * readahead_folio - Get the next folio to read.
> + * @ractl: The current readahead request.
> + *
> + * Context: The folio is locked.  The caller should unlock the folio once
> + * all I/O to that folio has completed.
> + * Return: A pointer to the next folio, or %NULL if we are done.
> + */
> +static inline struct folio *readahead_folio(struct readahead_control *ractl)
> +{
> +	struct folio *folio = __readahead_folio(ractl);
>  
> -	return page;
> +	folio_put(folio);

This will oops if __readahead_folio() returns NULL.

> +	return folio;
>  }


```
