Skip to contentSkip to conversation

ocfs2: remove unnecessary NULL check in ocfs2_grab_folios()

PATCH Applied Dan Carpenter 3 participants 3 messages Aug 19, 2025 – Aug 20, 2025

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

PATCH 1/1 ocfs2: remove unnecessary NULL check in ocfs2_grab_folios()

Smatch complains that checking "folios" for NULL doesn't make sense because it has already been dereferenced at this point. Really passing a NULL "folios" pointer to ocfs2_grab_folios() doesn't make sense, and fortunately none of the callers do that. Delete the unnecessary NULL check.

---
 fs/ocfs2/alloc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ocfs2/alloc.c +1 -2
index 821cb7874685..162711cc5b20 100644
@@ -6928,8 +6928,7 @@ static int ocfs2_grab_folios(struct inode *inode, loff_t start, loff_t end,
 
 out:
 	if (ret != 0) {
-		if (folios)
-			ocfs2_unlock_and_free_folios(folios, numfolios);
+		ocfs2_unlock_and_free_folios(folios, numfolios);
 		numfolios = 0;
 	}
 
Signature · 1 line
2.47.2
Reviewed-by on v1 1/1
#1 lore raw

Re: [External] : [PATCH] ocfs2: remove unnecessary NULL check in ocfs2_grab_folios()

Quoted 16 lines · Dan Carpenter

Smatch complains that checking "folios" for NULL doesn't make sense because it has already been dereferenced at this point. Really passing a NULL "folios" pointer to ocfs2_grab_folios() doesn't make sense, and fortunately none of the callers do that. Delete the unnecessary NULL check.

---
  fs/ocfs2/alloc.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
fs/ocfs2/alloc.c +0 -0
index 821cb7874685..162711cc5b20 100644

fs/ocfs2/alloc.c static int ocfs2_grab_folios(struct inode *inode, loff_t start, loff_t end, · line 6934

Quoted 9 lines
fs/ocfs2/alloc.c +1 -2
@@ -6928,8 +6928,7 @@ static int ocfs2_grab_folios(struct inode *inode, loff_t start, loff_t end,
 
  out:
  	if (ret != 0) {
-		if (folios)
-			ocfs2_unlock_and_free_folios(folios, numfolios);
+		ocfs2_unlock_and_free_folios(folios, numfolios);
  		numfolios = 0;
  	}
 
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 7 lines · Dan Carpenter

Smatch complains that checking "folios" for NULL doesn't make sense because it has already been dereferenced at this point. Really passing a NULL "folios" pointer to ocfs2_grab_folios() doesn't make sense, and fortunately none of the callers do that. Delete the unnecessary NULL check.

Quoted 18 lines
---
 fs/ocfs2/alloc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ocfs2/alloc.c +1 -2
index 821cb7874685..162711cc5b20 100644
@@ -6928,8 +6928,7 @@ static int ocfs2_grab_folios(struct inode *inode, loff_t start, loff_t end,
 
 out:
 	if (ret != 0) {
-		if (folios)
-			ocfs2_unlock_and_free_folios(folios, numfolios);
+		ocfs2_unlock_and_free_folios(folios, numfolios);
 		numfolios = 0;
 	}