linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hugetlbfs: fix an NULL vs IS_ERR() bug
@ 2023-09-28  5:17 Dan Carpenter
  2023-09-28  7:42 ` Sidhartha Kumar
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2023-09-28  5:17 UTC (permalink / raw)
  To: Sidhartha Kumar
  Cc: Mike Kravetz, Muchun Song, Andrew Morton, linux-mm,
	kernel-janitors

This code was converted from using find_lock_page() which returns NULL,
to calling filemap_lock_hugetlb_folio() which returns -ENOENT.  The
check needs to be updated to match.  Also IS_ERR() has an unlikely()
built in so we can remove that.

Fixes: 4649d8d5bb81 ("mm/filemap: remove hugetlb special casing in filemap.c")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
filemap_lock_hugetlb_folio() can return NULL if huge tables are disabled
but that isn't the case here so there is no need to check for that.

 fs/hugetlbfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 3f2f0a4bfad0..91034b6e5b69 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -354,7 +354,7 @@ static ssize_t hugetlbfs_read_iter(struct kiocb *iocb, struct iov_iter *to)
 
 		/* Find the folio */
 		folio = filemap_lock_hugetlb_folio(h, mapping, index);
-		if (unlikely(folio == NULL)) {
+		if (IS_ERR(folio)) {
 			/*
 			 * We have a HOLE, zero out the user-buffer for the
 			 * length of the hole or request.
-- 
2.39.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-28  7:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-28  5:17 [PATCH] hugetlbfs: fix an NULL vs IS_ERR() bug Dan Carpenter
2023-09-28  7:42 ` Sidhartha Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).