Skip to content

Commit 2055a99

Browse files
XidianGeneraldavem330
authored andcommitted
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: 9e99bfe ("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>
1 parent 29d98f5 commit 2055a99

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3978,11 +3978,15 @@ static int bond_neigh_init(struct neighbour *n)
39783978

39793979
rcu_read_lock();
39803980
slave = bond_first_slave_rcu(bond);
3981-
if (!slave)
3981+
if (!slave) {
3982+
ret = -EINVAL;
39823983
goto out;
3984+
}
39833985
slave_ops = slave->dev->netdev_ops;
3984-
if (!slave_ops->ndo_neigh_setup)
3986+
if (!slave_ops->ndo_neigh_setup) {
3987+
ret = -EINVAL;
39853988
goto out;
3989+
}
39863990

39873991
/* TODO: find another way [1] to implement this.
39883992
* Passing a zeroed structure is fragile,

0 commit comments

Comments
 (0)