From: Changcheng Deng <deng.changcheng@xxxxxxxxxx> A bug was found by coccinelle: folio is NULL but dereferenced Therefore,added a check to make sure 'folio' is not NULL. Reported-by: Zeal Robot <zealci@xxxxxxxxxx> Signed-off-by: Changcheng Deng <deng.changcheng@xxxxxxxxxx> Signed-off-by: Yi Wang <wang.yi59@xxxxxxxxxx> --- mm/folio-compat.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/folio-compat.c b/mm/folio-compat.c index 5b6ae1d..bee45e7 100644 --- a/mm/folio-compat.c +++ b/mm/folio-compat.c @@ -123,8 +123,9 @@ 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)) - return &folio->page; + if ((fgp_flags & FGP_HEAD) || xa_is_value(folio)) + if (folio != NULL) + return &folio->page; return folio_file_page(folio, index); } EXPORT_SYMBOL(pagecache_get_page); -- 1.8.3.1