linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] filemap: fix error pointer dereference in filemap_fault()
@ 2024-07-16  2:25 Ma Ke
  2024-07-16  2:30 ` Matthew Wilcox
  0 siblings, 1 reply; 2+ messages in thread
From: Ma Ke @ 2024-07-16  2:25 UTC (permalink / raw)
  To: willy, akpm; +Cc: linux-fsdevel, linux-mm, linux-kernel, Ma Ke

This code calls folio_put() on an error pointer which will lead to a
crash.  Check for both error pointers and NULL pointers before calling
folio_put().

Fixes: 38a55db9877c ("filemap: Handle error return from __filemap_get_folio()")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/filemap.c b/mm/filemap.c
index 657bcd887fdb..cd26617d8987 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3420,7 +3420,7 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
 	 * re-find the vma and come back and find our hopefully still populated
 	 * page.
 	 */
-	if (!IS_ERR(folio))
+	if (!IS_ERR_OR_NULL(folio))
 		folio_put(folio);
 	if (mapping_locked)
 		filemap_invalidate_unlock_shared(mapping);
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-16  2:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-16  2:25 [PATCH] filemap: fix error pointer dereference in filemap_fault() Ma Ke
2024-07-16  2:30 ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).