: tipc: Fix oops on send prior to entering networked mode

Submitted by Neil Horman on Feb. 24, 2010, 9:19 p.m.

Details

Message ID 20100224211919.GD15380@hmsreliant.think-freely.org
State Superseded
Delegated to: David Miller
Headers show

Commit Message

Neil Horman Feb. 24, 2010, 9:19 p.m.
As noted in my previous note, I'd agreed tht the preiviously posted patches for
the various tipc patches we encountered were sufficient for the oops at hand.
This patch closes the race condition thats left open after the application of
those patches.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>


 include/net/tipc/tipc.h |    3 ++-
 net/tipc/net.c          |    8 +++++---
 2 files changed, 7 insertions(+), 4 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch hide | download patch | download mbox

diff --git a/include/net/tipc/tipc.h b/include/net/tipc/tipc.h
index 9566608..14076e9 100644
--- a/include/net/tipc/tipc.h
+++ b/include/net/tipc/tipc.h
@@ -54,7 +54,8 @@  u32 tipc_get_addr(void);
 
 #define TIPC_NOT_RUNNING  0
 #define TIPC_NODE_MODE    1
-#define TIPC_NET_MODE     2
+#define TIPC_TRANS_MODE	  2
+#define TIPC_NET_MODE     3
 
 typedef void (*tipc_mode_event)(void *usr_handle, int mode, u32 addr);
 
diff --git a/net/tipc/net.c b/net/tipc/net.c
index 7906608..daeafe7 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -278,7 +278,7 @@  int tipc_net_start(u32 addr)
 	tipc_cfg_stop();
 
 	tipc_own_addr = addr;
-	tipc_mode = TIPC_NET_MODE;
+	tipc_mode = TIPC_TRANS_MODE;
 	tipc_named_reinit();
 	tipc_port_reinit();
 
@@ -295,18 +295,20 @@  int tipc_net_start(u32 addr)
 	info("Started in network mode\n");
 	info("Own node address %s, network identity %u\n",
 	     addr_string_fill(addr_string, tipc_own_addr), tipc_net_id);
+	tipc_mode = TIPC_NET_MODE;
 	return 0;
 }
 
 void tipc_net_stop(void)
 {
-	if (tipc_mode != TIPC_NET_MODE)
+	if (tipc_mode < TIPC_TRANS_MODE)
 		return;
+	tipc_mode = TIPC_TRANS_MODE;
 	write_lock_bh(&tipc_net_lock);
 	tipc_bearer_stop();
-	tipc_mode = TIPC_NODE_MODE;
 	tipc_bclink_stop();
 	net_stop();
+	tipc_mode = TIPC_NODE_MODE;
 	write_unlock_bh(&tipc_net_lock);
 	info("Left network mode \n");
 }