Skip to contentSkip to conversation

ocfs2: fix uninitialized variable in ocfs2_test_suballoc_bit()

PATCH In review Dan Carpenter 2 participants 2 messages Dec 18, 2025 1 message not in the archive OCFS2

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 ocfs2: fix uninitialized variable in ocfs2_test_suballoc_bit()

In reply to a message not in the archive

The ocfs2_read_hint_group_descriptor() function sets "*released = 1;" but nothing ever sets it to zero so it's used without being initialized. Initialize it to zero.

Fixes acb8a8335a64 ("ocfs2: detect released suballocator BG for fh_to_[dentry|parent]")

---
These days everyone has CONFIG_INIT_STACK_ALL_ZERO enabled so we never detect these bugs. There are a couple distros which don't, I've heard. But in testing, I always encourage people to use CONFIG_INIT_STACK_ALL_PATTERN=y

 fs/ocfs2/suballoc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/suballoc.c +1 -1
index 72c7559c1a2b..79d1325b2111 100644
@@ -3163,7 +3163,7 @@ static int ocfs2_test_suballoc_bit(struct ocfs2_super *osb,
 	struct ocfs2_group_desc *group;
 	struct buffer_head *group_bh = NULL;
 	u64 bg_blkno;
-	int status, quiet = 0, released;
+	int status, quiet = 0, released = 0;
 
 	trace_ocfs2_test_suballoc_bit((unsigned long long)blkno,
 				      (unsigned int)bit);
Signature · 1 line
2.51.0
reviewer Reviewed-by on v1 1/1
#2 lore raw
Quoted 6 lines · Dan Carpenter

The ocfs2_read_hint_group_descriptor() function sets "*released = 1;" but nothing ever sets it to zero so it's used without being initialized. Initialize it to zero.

Fixes acb8a8335a64 ("ocfs2: detect released suballocator BG for fh_to_[dentry|parent]")

Many thanks for catching this bug.
I will try the config CONFIG_INIT_STACK_ALL_PATTERN=y

Quoted 25 lines

---
These days everyone has CONFIG_INIT_STACK_ALL_ZERO enabled so we never detect these bugs. There are a couple distros which don't, I've heard. But in testing, I always encourage people to use CONFIG_INIT_STACK_ALL_PATTERN=y

 fs/ocfs2/suballoc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/suballoc.c +1 -1
index 72c7559c1a2b..79d1325b2111 100644
@@ -3163,7 +3163,7 @@ static int ocfs2_test_suballoc_bit(struct ocfs2_super *osb,
 	struct ocfs2_group_desc *group;
 	struct buffer_head *group_bh = NULL;
 	u64 bg_blkno;
-	int status, quiet = 0, released;
+	int status, quiet = 0, released = 0;
 
 	trace_ocfs2_test_suballoc_bit((unsigned long long)blkno,
 				      (unsigned int)bit);
Signature · 1 line
2.51.0