From: Ma Ke <make24@iscas.ac.cn>
To: willy@infradead.org, akpm@linux-foundation.org
Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, Ma Ke <make24@iscas.ac.cn>
Subject: [PATCH] filemap: fix error pointer dereference in filemap_fault()
Date: Tue, 16 Jul 2024 10:25:18 +0800 [thread overview]
Message-ID: <20240716022518.430237-1-make24@iscas.ac.cn> (raw)
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
next reply other threads:[~2024-07-16 2:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-16 2:25 Ma Ke [this message]
2024-07-16 2:30 ` Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240716022518.430237-1-make24@iscas.ac.cn \
--to=make24@iscas.ac.cn \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox