On 23.06.23 08:26, Dan Carpenter wrote:
The filemap_get_folio() function doesn't returns NULL, it returns error
pointers. So the "return folio != NULL;" statement means
hugetlbfs_pagecache_present() always returns true.
Fixes: 267d6792f43b ("hugetlb: revert use of page_cache_next_miss()")
Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
---
mm/hugetlb.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index cb9077b96b43..bce28cca73a1 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -5731,9 +5731,10 @@ static bool hugetlbfs_pagecache_present(struct hstate *h,
struct folio *folio;
folio = filemap_get_folio(mapping, idx);
- if (!IS_ERR(folio))
- folio_put(folio);
- return folio != NULL;
+ if (IS_ERR(folio))
+ return false;
+ folio_put(folio);
+ return true;
}
int hugetlb_add_to_page_cache(struct folio *folio, struct address_space *mapping,
Reviewed-by: David Hildenbrand <david@xxxxxxxxxx>
--
Cheers,
David / dhildenb