Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: bonding: fix error return code of bond_neigh_init()

When slave is NULL or slave_ops->ndo_neigh_setup is NULL, no error
return code of bond_neigh_init() is assigned.
To fix this bug, ret is assigned with -EINVAL in these cases.

Fixes: 9e99bfefdbce ("bonding: fix bond_neigh_init()")
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jia-Ju Bai and committed by
David S. Miller
2055a99d 29d98f54

+6 -2
+6 -2
drivers/net/bonding/bond_main.c
··· 3978 3978 3979 3979 rcu_read_lock(); 3980 3980 slave = bond_first_slave_rcu(bond); 3981 - if (!slave) 3981 + if (!slave) { 3982 + ret = -EINVAL; 3982 3983 goto out; 3984 + } 3983 3985 slave_ops = slave->dev->netdev_ops; 3984 - if (!slave_ops->ndo_neigh_setup) 3986 + if (!slave_ops->ndo_neigh_setup) { 3987 + ret = -EINVAL; 3985 3988 goto out; 3989 + } 3986 3990 3987 3991 /* TODO: find another way [1] to implement this. 3988 3992 * Passing a zeroed structure is fragile,