Skip to contentSkip to conversation

bonding: uninitialized variable in bond_miimon_inspect()

PATCH Applied Dan Carpenter 4 participants 8 messages Nov 28, 2022 – Dec 1, 2022

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

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

The "ignore_updelay" variable needs to be initialized to false.

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

---
v2: Re-order so the declarations are in reverse Christmas tree order

Don't forget about:
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'

 drivers/net/bonding/bond_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +1 -1
index c87481033995..e01bb0412f1c 100644
@@ -2524,10 +2524,10 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in
 /* called with rcu_read_lock() */
 static int bond_miimon_inspect(struct bonding *bond)
 {
+	bool ignore_updelay = false;
 	int link_state, commit = 0;
 	struct list_head *iter;
 	struct slave *slave;
-	bool ignore_updelay;
 
 	if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) {
 		ignore_updelay = !rcu_dereference(bond->curr_active_slave);
Signature · 1 line
2.35.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Dan Carpenter

The "ignore_updelay" variable needs to be initialized to false.

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

---
v2: Re-order so the declarations are in reverse Christmas tree order

Thanks,

Quoted 3 lines

Don't forget about:
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 think that warning can be ignored, as bond_update_slave_arr() does consider the return value of bond_3ad_get_active_agg_info() but chooses to not bubble it up. Though the author of the function is the best person to answer it, at this point, it looks OK to me. Maybe a separate patch to address it would help to get the attention of the author.

Quoted 22 lines
 drivers/net/bonding/bond_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +1 -2
index c87481033995..e01bb0412f1c 100644
@@ -2524,10 +2524,10 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in
 /* called with rcu_read_lock() */
 static int bond_miimon_inspect(struct bonding *bond)
 {
+       bool ignore_updelay = false;
        int link_state, commit = 0;
        struct list_head *iter;
        struct slave *slave;
-       bool ignore_updelay;
 
        if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) {
                ignore_updelay = !rcu_dereference(bond->curr_active_slave);
--

2.35.1

#2 lore raw
Quoted 16 lines · Pavan Chebbi
Quoted 8 lines · Dan Carpenter

The "ignore_updelay" variable needs to be initialized to false.

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

---
v2: Re-order so the declarations are in reverse Christmas tree order

Thanks,

Quoted 3 lines

Don't forget about:
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'

Quoted 6 lines

I think that warning can be ignored, as bond_update_slave_arr() does consider the return value of bond_3ad_get_active_agg_info() but chooses to not bubble it up. Though the author of the function is the best person to answer it, at this point, it looks OK to me. Maybe a separate patch to address it would help to get the attention of the author.

Heh... That's slightly vague.

You're wrong to say that none of the callers care about the error code. It is checked in bond_slave_arr_handler().

regards,
dan carpenter

#3 lore raw
Quoted 24 lines · Dan Carpenter
Quoted 16 lines · Pavan Chebbi
Quoted 8 lines · Dan Carpenter

The "ignore_updelay" variable needs to be initialized to false.

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

---
v2: Re-order so the declarations are in reverse Christmas tree order

Thanks,

Quoted 3 lines

Don't forget about:
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'

Quoted 6 lines

I think that warning can be ignored, as bond_update_slave_arr() does consider the return value of bond_3ad_get_active_agg_info() but chooses to not bubble it up. Though the author of the function is the best person to answer it, at this point, it looks OK to me. Maybe a separate patch to address it would help to get the attention of the author.

Quoted 4 lines

Heh... That's slightly vague.

You're wrong to say that none of the callers care about the error code. It is checked in bond_slave_arr_handler().

If you don't know that's fine also... All the maintainers are CC'd. If they really care they can take a look otherwise there are so many other obvious bugs to care about and this is very minor.

regards,
dan carpenter

#4 lore raw
Quoted 26 lines · Dan Carpenter
Quoted 24 lines · Dan Carpenter
Quoted 22 lines · Pavan Chebbi
Quoted 8 lines · Dan Carpenter

The "ignore_updelay" variable needs to be initialized to false.

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

---
v2: Re-order so the declarations are in reverse Christmas tree order

Thanks,

Quoted 3 lines

Don't forget about:
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 think that warning can be ignored, as bond_update_slave_arr() does consider the return value of bond_3ad_get_active_agg_info() but chooses to not bubble it up. Though the author of the function is the best person to answer it, at this point, it looks OK to me. Maybe a separate patch to address it would help to get the attention of the author.

Quoted 9 lines
Quoted 4 lines

Heh... That's slightly vague.

You're wrong to say that none of the callers care about the error code. It is checked in bond_slave_arr_handler().

If you don't know that's fine also... All the maintainers are CC'd. If they really care they can take a look otherwise there are so many other obvious bugs to care about and this is very minor.

No, I did not say nobody cares about the error code. I just said that bond_update_slave_arr() does care about bond_3ad_get_active_agg_info()'s return value, takes appropriate action and returns success to its caller. I think this is the scope and context of the warning message.
To me this looks OK, but again, the maintainer/author is the best judge.

Quoted 3 lines

regards,
dan carpenter

Acked-by on v2 1/1
#5 lore raw
In reply to Dan Carpenter
Quoted 4 lines · Dan Carpenter

The "ignore_updelay" variable needs to be initialized to false.

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

---
v2: Re-order so the declarations are in reverse Christmas tree order

Don't forget about:
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'

The code around the cited line is correct. A -1 return from
bond_3ad_get_active_agg_info is not indicative of an error in the sense that something has failed, but indicates that there is no active aggregator. The code correctly returns 0 from bond_update_slave_arr, as returning non-zero would cause bond_slave_arr_handler to loop, retrying the call to bond_update_slave_arr (via workqueue).

	-J
Quoted 22 lines

drivers/net/bonding/bond_main.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +1 -1
index c87481033995..e01bb0412f1c 100644
@@ -2524,10 +2524,10 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in
 /* called with rcu_read_lock() */
 static int bond_miimon_inspect(struct bonding *bond)
 {
+	bool ignore_updelay = false;
 	int link_state, commit = 0;
 	struct list_head *iter;
 	struct slave *slave;
-	bool ignore_updelay;
 
 	if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) {
 		ignore_updelay = !rcu_dereference(bond->curr_active_slave);
Signature · 1 line
2.35.1

---
-Jay Vosburgh, [email protected]

#6 lore raw
Quoted 15 lines · Jay Vosburgh
Quoted 4 lines · Dan Carpenter

The "ignore_updelay" variable needs to be initialized to false.

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

---
v2: Re-order so the declarations are in reverse Christmas tree order

Don't forget about:
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'

Quoted 7 lines

The code around the cited line is correct. A -1 return from
bond_3ad_get_active_agg_info is not indicative of an error in the sense that something has failed, but indicates that there is no active aggregator. The code correctly returns 0 from bond_update_slave_arr, as returning non-zero would cause bond_slave_arr_handler to loop, retrying the call to bond_update_slave_arr (via workqueue).

Awesome, thanks for taking a look at this.

regards,
dan carpenter

#7 lore raw
In reply to Dan Carpenter
This patch was applied to netdev/net-next.git (master) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by Paolo Abeni <[email protected]>:

Quoted 8 lines · On Mon, 28 Nov 2022 14:06:14 +0300 you wrote:

The "ignore_updelay" variable needs to be initialized to false.

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

---
v2: Re-order so the declarations are in reverse Christmas tree order

[...]

Here is the summary with links:
- [net-next,v2] bonding: uninitialized variable in bond_miimon_inspect()

    https://git.kernel.org/netdev/net-next/c/e5214f363dab

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html