[PATCH next] squashfs: Fix a NULL vs IS_ERR() bug

Dan Carpenter posted 1 patch 11 months, 2 weeks ago
fs/squashfs/file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH next] squashfs: Fix a NULL vs IS_ERR() bug
Posted by Dan Carpenter 11 months, 2 weeks ago
The __filemap_get_folio() functoin never returns NULL, it returns
error pointers.  This incorrect check would lead to an Oops on the
following line when we pass "push_folio" to folio_test_uptodate().

Fixes: 43c73ba98b2c ("squashfs; convert squashfs_copy_cache() to take a folio")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 fs/squashfs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
index da25d6fa45ce..eef1dd462592 100644
--- a/fs/squashfs/file.c
+++ b/fs/squashfs/file.c
@@ -409,7 +409,7 @@ void squashfs_copy_cache(struct folio *folio,
 					FGP_LOCK|FGP_CREAT|FGP_NOFS|FGP_NOWAIT,
 					mapping_gfp_mask(mapping));
 
-		if (!push_folio)
+		if (IS_ERR(push_folio))
 			continue;
 
 		if (folio_test_uptodate(push_folio))
-- 
2.45.2
Re: [PATCH next] squashfs: Fix a NULL vs IS_ERR() bug
Posted by Phillip Lougher 11 months, 1 week ago

On 1/8/25 09:16, Dan Carpenter wrote:
> The __filemap_get_folio() functoin never returns NULL, it returns
> error pointers.  This incorrect check would lead to an Oops on the
> following line when we pass "push_folio" to folio_test_uptodate().
> 
> Fixes: 43c73ba98b2c ("squashfs; convert squashfs_copy_cache() to take a folio")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Phillip Lougher <phillip@squashfs.org.uk>