]> git.baikalelectronics.ru Git - kernel.git/commit
bonding: fix a div error caused by the slave release path
authorNikolay Aleksandrov <nikolay@redhat.com>
Wed, 26 Feb 2014 13:20:30 +0000 (14:20 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 26 Feb 2014 22:09:09 +0000 (17:09 -0500)
commit2376509b9136c21c7119cf0db277520e586e59d0
treeee61b4fe5ed2665a595d9119afe433608c19e21e
parentf25bfc099cae93dd4c81457ee13556a0414c6ff7
bonding: fix a div error caused by the slave release path

There's a bug in the slave release function which leads the transmit
functions which use the bond->slave_cnt to a div by 0 because we might
just have released our last slave and made slave_cnt == 0 but at the same
time we may have a transmitter after the check for an empty list which will
fetch it and use it in the slave id calculation.
Fix it by moving the slave_cnt after synchronize_rcu so if this was our
last slave any new transmitters will see an empty slave list which is
checked after rcu lock but before calling the mode transmit functions
which rely on bond->slave_cnt.

Fixes: 51cf18719e ("bonding: initial RCU conversion")
CC: Veaceslav Falico <vfalico@redhat.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: David S. Miller <davem@davemloft.net>
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Acked-by: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_main.c