diff options
author | nikolay@redhat.com <nikolay@redhat.com> | 2013-02-18 02:59:03 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-02-19 00:51:08 -0500 |
commit | e0809dbc47dea83eba7a9abb70e87470904d4372 (patch) | |
tree | 210276bba9031e3df771084b87aacf5bfe4e0462 | |
parent | b59340c2c0508d280f10658ad662fa56a39c74c2 (diff) |
bonding: Fix initialize after use for 3ad machine state spinlock
The 3ad machine state spinlock can be used before it is inititialized
while doing bond_enslave() (and the port is being initialized) since
port->slave is set before the lock is prepared, thus causing soft
lock-ups and a multitude of other nasty bugs.
[ Rename __initialize_port_locks() variable name to 'slave' -DaveM ]
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/bonding/bond_3ad.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index 0e45b400b6fc..fc58d118d844 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c | |||
@@ -389,13 +389,13 @@ static u8 __get_duplex(struct port *port) | |||
389 | 389 | ||
390 | /** | 390 | /** |
391 | * __initialize_port_locks - initialize a port's STATE machine spinlock | 391 | * __initialize_port_locks - initialize a port's STATE machine spinlock |
392 | * @port: the port we're looking at | 392 | * @port: the slave of the port we're looking at |
393 | * | 393 | * |
394 | */ | 394 | */ |
395 | static inline void __initialize_port_locks(struct port *port) | 395 | static inline void __initialize_port_locks(struct slave *slave) |
396 | { | 396 | { |
397 | // make sure it isn't called twice | 397 | // make sure it isn't called twice |
398 | spin_lock_init(&(SLAVE_AD_INFO(port->slave).state_machine_lock)); | 398 | spin_lock_init(&(SLAVE_AD_INFO(slave).state_machine_lock)); |
399 | } | 399 | } |
400 | 400 | ||
401 | //conversions | 401 | //conversions |
@@ -1910,6 +1910,7 @@ int bond_3ad_bind_slave(struct slave *slave) | |||
1910 | 1910 | ||
1911 | ad_initialize_port(port, bond->params.lacp_fast); | 1911 | ad_initialize_port(port, bond->params.lacp_fast); |
1912 | 1912 | ||
1913 | __initialize_port_locks(slave); | ||
1913 | port->slave = slave; | 1914 | port->slave = slave; |
1914 | port->actor_port_number = SLAVE_AD_INFO(slave).id; | 1915 | port->actor_port_number = SLAVE_AD_INFO(slave).id; |
1915 | // key is determined according to the link speed, duplex and user key(which is yet not supported) | 1916 | // key is determined according to the link speed, duplex and user key(which is yet not supported) |
@@ -1932,8 +1933,6 @@ int bond_3ad_bind_slave(struct slave *slave) | |||
1932 | port->next_port_in_aggregator = NULL; | 1933 | port->next_port_in_aggregator = NULL; |
1933 | 1934 | ||
1934 | __disable_port(port); | 1935 | __disable_port(port); |
1935 | __initialize_port_locks(port); | ||
1936 | |||
1937 | 1936 | ||
1938 | // aggregator initialization | 1937 | // aggregator initialization |
1939 | aggregator = &(SLAVE_AD_INFO(slave).aggregator); | 1938 | aggregator = &(SLAVE_AD_INFO(slave).aggregator); |