Re: [PATCH] mm/hugetlb: fix hugetlbfs_pagecache_present()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06/23/23 09: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;
>  }

Thank you Dan!

I noted the changed behavior of filemap_get_folio in the commit message
and still missed that comparison to NULL. :(

-- 
Mike Kravetz

>  
>  int hugetlb_add_to_page_cache(struct folio *folio, struct address_space *mapping,
> -- 
> 2.39.2
> 




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux