Skip to content

Commit

Permalink
net: bonding: fix error return code of bond_neigh_init()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
XidianGeneral authored and davem330 committed Mar 8, 2021
1 parent 29d98f5 commit 2055a99
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/net/bonding/bond_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3978,11 +3978,15 @@ static int bond_neigh_init(struct neighbour *n)

rcu_read_lock();
slave = bond_first_slave_rcu(bond);
if (!slave)
if (!slave) {
ret = -EINVAL;
goto out;
}
slave_ops = slave->dev->netdev_ops;
if (!slave_ops->ndo_neigh_setup)
if (!slave_ops->ndo_neigh_setup) {
ret = -EINVAL;
goto out;
}

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

0 comments on commit 2055a99

Please sign in to comment.