tipc: make media_ptr pointed netdevice valid
authorYing Xue <ying.xue@windriver.com>
Mon, 21 Apr 2014 02:55:49 +0000 (10:55 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 23 Apr 2014 01:17:53 +0000 (21:17 -0400)
The 'media_ptr' pointer in bearer structure which points to network
device, is protected by RCU. So, before netdevice is released,
synchronize_net() should be involved to prevent no any user of
the netdevice on read side from accessing it after it is freed.

Signed-off-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Tested-by: Erik Hugne <erik.hugne@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/bearer.c

index 1bd96eb465e19ed09a8cf0d1d3364939c76b2a3a..402e99472a630f65cd8bc56bf08fa9a752875adc 100644 (file)
@@ -471,6 +471,7 @@ void tipc_disable_l2_media(struct tipc_bearer *b)
        dev = (struct net_device *)rtnl_dereference(b->media_ptr);
        RCU_INIT_POINTER(b->media_ptr, NULL);
        RCU_INIT_POINTER(dev->tipc_ptr, NULL);
+       synchronize_net();
        dev_put(dev);
 }