Skip to contentSkip to conversation

bonding: uninitialized variable in bond_miimon_inspect()

PATCH Superseded Dan Carpenter 2 participants 2 messages Nov 28, 2022

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bonding: uninitialized variable in bond_miimon_inspect()

The "ignore_updelay" variable needs to be initialized to false to prevent an uninitialized variable bug.

Fixes f8a65ab2f3ff ("bonding: fix link recovery in mode 2 when updelay is nonzero")

---

This was found by Smatch. Another Smatch warning that might be worth investigating is:

drivers/net/bonding/bond_main.c:5071 bond_update_slave_arr() warn: missing error code here? 'bond_3ad_get_active_agg_info()' failed. 'ret' = '0'

I don't know the code well enough to say if that's a real bug.

 drivers/net/bonding/bond_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +1 -1
index c87481033995..8a57a5681461 100644
@@ -2527,7 +2527,7 @@ static int bond_miimon_inspect(struct bonding *bond)
 	int link_state, commit = 0;
 	struct list_head *iter;
 	struct slave *slave;
-	bool ignore_updelay;
+	bool ignore_updelay = false;
 
 	if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) {
 		ignore_updelay = !rcu_dereference(bond->curr_active_slave);
Signature · 1 line
2.35.1
#1 lore raw
Quoted 23 lines · Dan Carpenter

The "ignore_updelay" variable needs to be initialized to false to prevent an uninitialized variable bug.

Fixes f8a65ab2f3ff ("bonding: fix link recovery in mode 2 when updelay is nonzero")

---

This was found by Smatch. Another Smatch warning that might be worth investigating is:

drivers/net/bonding/bond_main.c:5071 bond_update_slave_arr() warn: missing error code here? 'bond_3ad_get_active_agg_info()' failed. 'ret' = '0'

I don't know the code well enough to say if that's a real bug.

 drivers/net/bonding/bond_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +0 -0
index c87481033995..8a57a5681461 100644

drivers/net/bonding/bond_main.c static int bond_miimon_inspect(struct bonding *bond) · line 2530

Quoted 5 lines
drivers/net/bonding/bond_main.c +1 -1
@@ -2527,7 +2527,7 @@ static int bond_miimon_inspect(struct bonding *bond)
        int link_state, commit = 0;
        struct list_head *iter;
        struct slave *slave;
-       bool ignore_updelay;
+       bool ignore_updelay = false;

Looks good to me. But can we have the declaration follow the reverse xmas tree ordering?
Thanks

Quoted 6 lines
drivers/net/bonding/bond_main.c +0 -1
        if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) {
                ignore_updelay = !rcu_dereference(bond->curr_active_slave);
--

2.35.1