diff --git a/mm/filemap.c b/mm/filemap.c
index 4f3753f0a158..960f389e2d3b 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2360,7 +2360,10 @@ static int filemap_read_folio(struct file *file, filler_t filler,
 	/* Start the actual read. The read will unlock the page. */
 	if (unlikely(workingset))
 		psi_memstall_enter(&pflags);
-	error = filler(file, folio);
+	if (filler)
+		error = filler(file, folio);
+	else
+		return -EIO;
 	if (unlikely(workingset))
 		psi_memstall_leave(&pflags);
 	if (error)