Skip to contentSkip to conversation

gfs2: Fix a NULL vs IS_ERR() bug in gfs2_find_jhead()

PATCH Applied Dan Carpenter 2 participants 2 messages Mar 12, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gfs2: Fix a NULL vs IS_ERR() bug in gfs2_find_jhead()

The filemap_grab_folio() function doesn't return NULL, it returns error pointers. Fix the check to match.

Fixes 40829760096d ("gfs2: Convert gfs2_find_jhead() to use a folio")
---
 fs/gfs2/lops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/gfs2/lops.c +2 -2
index 3853c422040b..0fd3b5ec7d8c 100644
@@ -530,8 +530,8 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head,
 			if (!folio) {
 				folio = filemap_grab_folio(mapping,
 						block >> shift);
-				if (!folio) {
-					ret = -ENOMEM;
+				if (IS_ERR(folio)) {
+					ret = PTR_ERR(folio);
 					done = true;
 					goto out;
 				}
Signature · 1 line
2.47.2
#1 lore raw

Am Mi., 12. März 2025 um 09:33 Uhr schrieb Dan Carpenter <[email protected]>:

Quoted 25 lines

The filemap_grab_folio() function doesn't return NULL, it returns error pointers. Fix the check to match.

Fixes 40829760096d ("gfs2: Convert gfs2_find_jhead() to use a folio")
---
 fs/gfs2/lops.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/gfs2/lops.c +2 -3
index 3853c422040b..0fd3b5ec7d8c 100644
@@ -530,8 +530,8 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head,
                        if (!folio) {
                                folio = filemap_grab_folio(mapping,
                                                block >> shift);
-                               if (!folio) {
-                                       ret = -ENOMEM;
+                               if (IS_ERR(folio)) {
+                                       ret = PTR_ERR(folio);
                                        done = true;
                                        goto out;
                                }
--
Quoted 1 line

2.47.2

Applied, thanks.

Andreas