* [PATCH net] bonding: initialize err for empty target lists
@ 2026-08-13 15:31 Ruoyu Wang
2026-08-13 16:03 ` Nikolay Aleksandrov
0 siblings, 1 reply; 2+ messages in thread
From: Ruoyu Wang @ 2026-08-13 15:31 UTC (permalink / raw)
To: netdev
Cc: jv, andrew+netdev, davem, edumazet, kuba, pabeni, linux-kernel,
Ruoyu Wang
Empty NLA_NESTED attributes are valid, and bonding uses them to clear
the ARP and NS target lists. When either target attribute is empty,
nla_for_each_nested() does not execute, so err retains an uninitialized
value before it is tested. The request can consequently return an
unpredictable error after clearing the targets.
Initialize err to zero so an empty target list completes successfully.
Non-empty lists still propagate errors from __bond_opt_set() unchanged.
This issue was found by a static analysis checker and confirmed by manual
source review.
Fixes: 4fb0ef585eb2 ("bonding: convert arp_ip_target to use the new option API")
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
drivers/net/bonding/bond_netlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index 4a11572f663d31..87d92d3cce4a88 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -220,7 +220,7 @@ static int bond_changelink(struct net_device *bond_dev, struct nlattr *tb[],
struct bonding *bond = netdev_priv(bond_dev);
struct bond_opt_value newval;
int miimon = 0;
- int err;
+ int err = 0;
if (!data)
return 0;
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net] bonding: initialize err for empty target lists
2026-08-13 15:31 [PATCH net] bonding: initialize err for empty target lists Ruoyu Wang
@ 2026-08-13 16:03 ` Nikolay Aleksandrov
0 siblings, 0 replies; 2+ messages in thread
From: Nikolay Aleksandrov @ 2026-08-13 16:03 UTC (permalink / raw)
To: Ruoyu Wang, netdev
Cc: jv, andrew+netdev, davem, edumazet, kuba, pabeni, linux-kernel
On 13/08/2026 18:31, Ruoyu Wang wrote:
> Empty NLA_NESTED attributes are valid, and bonding uses them to clear
> the ARP and NS target lists. When either target attribute is empty,
> nla_for_each_nested() does not execute, so err retains an uninitialized
> value before it is tested. The request can consequently return an
> unpredictable error after clearing the targets.
>
> Initialize err to zero so an empty target list completes successfully.
> Non-empty lists still propagate errors from __bond_opt_set() unchanged.
>
> This issue was found by a static analysis checker and confirmed by manual
> source review.
>
> Fixes: 4fb0ef585eb2 ("bonding: convert arp_ip_target to use the new option API")
> Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
> ---
> drivers/net/bonding/bond_netlink.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
> index 4a11572f663d31..87d92d3cce4a88 100644
> --- a/drivers/net/bonding/bond_netlink.c
> +++ b/drivers/net/bonding/bond_netlink.c
> @@ -220,7 +220,7 @@ static int bond_changelink(struct net_device *bond_dev, struct nlattr *tb[],
> struct bonding *bond = netdev_priv(bond_dev);
> struct bond_opt_value newval;
> int miimon = 0;
> - int err;
> + int err = 0;
>
> if (!data)
> return 0;
Oh well, I've missed they can be empty. :)
By the way you haven't CCed the Fixes commit author (me).
Thanks,
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-13 16:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13 15:31 [PATCH net] bonding: initialize err for empty target lists Ruoyu Wang
2026-08-13 16:03 ` Nikolay Aleksandrov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox