[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221018143639.5099-1-91tuocao@gmail.com>
Date: Tue, 18 Oct 2022 22:36:39 +0800
From: Tuo Cao <91tuocao@...il.com>
To: akpm@...ux-foundation.org
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
91tuocao@...il.com
Subject: [PATCH] mm: folio-compat: fix bug for pagecache_get_page
The folio returned from __filemap_get_folio may be a NULL, it will
causes the kernel crash when access folio->page.
Signed-off-by: Tuo Cao <91tuocao@...il.com>
---
mm/folio-compat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/folio-compat.c b/mm/folio-compat.c
index e1e23b4947d7..37ba33135506 100644
--- a/mm/folio-compat.c
+++ b/mm/folio-compat.c
@@ -108,7 +108,7 @@ struct page *pagecache_get_page(struct address_space *mapping, pgoff_t index,
struct folio *folio;
folio = __filemap_get_folio(mapping, index, fgp_flags, gfp);
- if ((fgp_flags & FGP_HEAD) || !folio || xa_is_value(folio))
+ if ((fgp_flags & FGP_HEAD) || xa_is_value(folio))
return &folio->page;
return folio_file_page(folio, index);
}
--
2.17.1
Powered by blists - more mailing lists