diff mbox series

[net-next] bonding: uninitialized variable in bond_miimon_inspect()

Message ID Y4RvS7Bns4Q8MorG@kili (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] bonding: uninitialized variable in bond_miimon_inspect() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 3 this patch: 3
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Dan Carpenter Nov. 28, 2022, 8:20 a.m. UTC
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")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---

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(-)

Comments

Pavan Chebbi Nov. 28, 2022, 8:44 a.m. UTC | #1
On Mon, Nov 28, 2022 at 1:51 PM Dan Carpenter <error27@gmail.com> wrote:
>
> 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")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
>
> 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(-)
>
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index c87481033995..8a57a5681461 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -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

>
>         if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) {
>                 ignore_updelay = !rcu_dereference(bond->curr_active_slave);
> --
> 2.35.1
>
diff mbox series

Patch

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index c87481033995..8a57a5681461 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -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);