From: Dan Carpenter <dan.carpenter@linaro.org>
To: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Muchun Song <muchun.song@linux.dev>,
Andrew Morton <akpm@linux-foundation.org>,
Sidhartha Kumar <sidhartha.kumar@oracle.com>,
linux-mm@kvack.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] mm/hugetlb: fix hugetlbfs_pagecache_present()
Date: Fri, 23 Jun 2023 09:26:02 +0300 [thread overview]
Message-ID: <efa86091-6a2c-4064-8f55-9b44e1313015@moroto.mountain> (raw)
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@linaro.org>
---
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,
--
2.39.2
next reply other threads:[~2023-06-23 6:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-23 6:26 Dan Carpenter [this message]
2023-06-23 6:37 ` Sidhartha Kumar
2023-06-27 9:48 ` David Hildenbrand
2023-07-03 18:58 ` Mike Kravetz
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=efa86091-6a2c-4064-8f55-9b44e1313015@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=akpm@linux-foundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=muchun.song@linux.dev \
--cc=sidhartha.kumar@oracle.com \
/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