Skip to contentSkip to conversation

rcu/nocb: Fix uninitialized variable in nocb_gp_wait()

PATCH In review Dan Carpenter 2 participants 2 messages Sep 23, 2019

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

PATCH 1/1 rcu/nocb: Fix uninitialized variable in nocb_gp_wait()

We never set this to false. This probably doesn't affect most people's runtime because GCC will automatically initialize it to false at certain common optimization levels. But that behavior is related to a bug in GCC and obviously should not be relied on.

Fixes 5d6742b37727 ("rcu/nocb: Use rcu_segcblist for no-CBs CPUs")
---
 kernel/rcu/tree_plugin.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree_plugin.h +1 -1
index 2defc7fe74c3..fa08d55f7040 100644
@@ -1946,7 +1946,7 @@ static void nocb_gp_wait(struct rcu_data *my_rdp)
 	int __maybe_unused cpu = my_rdp->cpu;
 	unsigned long cur_gp_seq;
 	unsigned long flags;
-	bool gotcbs;
+	bool gotcbs = false;
 	unsigned long j = jiffies;
 	bool needwait_gp = false; // This prevents actual uninitialized use.
 	bool needwake;
Signature · 1 line
2.20.1
maintainer
#1 lore raw
Quoted 7 lines · Dan Carpenter

We never set this to false. This probably doesn't affect most people's runtime because GCC will automatically initialize it to false at certain common optimization levels. But that behavior is related to a bug in GCC and obviously should not be relied on.

Fixes 5d6742b37727 ("rcu/nocb: Use rcu_segcblist for no-CBs CPUs")

Good catch! Queued for v5.5, thank you!

Thanx, Paul

Quoted 20 lines
---
 kernel/rcu/tree_plugin.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/tree_plugin.h +1 -1
index 2defc7fe74c3..fa08d55f7040 100644
@@ -1946,7 +1946,7 @@ static void nocb_gp_wait(struct rcu_data *my_rdp)
 	int __maybe_unused cpu = my_rdp->cpu;
 	unsigned long cur_gp_seq;
 	unsigned long flags;
-	bool gotcbs;
+	bool gotcbs = false;
 	unsigned long j = jiffies;
 	bool needwait_gp = false; // This prevents actual uninitialized use.
 	bool needwake;
Signature · 1 line
2.20.1