Message ID | 1772c296-1417-486f-8eef-171af2192681@moroto.mountain (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | hugetlbfs: fix an NULL vs IS_ERR() bug | expand |
On 9/27/23 10:17 PM, Dan Carpenter wrote: > 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. Reviewed-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
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.
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(-)