diff options
author | Allan Stephens <allan.stephens@windriver.com> | 2011-05-27 13:59:17 -0400 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2011-09-17 22:55:05 -0400 |
commit | bcd326e844c46e0533a79f91e75dea160469cf86 (patch) | |
tree | c1c6172089ca0ceb98625eb8ffb4f79979f91ce2 /net/tipc | |
parent | b4b5610223f17790419b03eaa962b0e3ecf930d7 (diff) |
tipc: Fix unsafe device list search when enabling bearer
Ensures that the device list lock is held while trying to locate
the Ethernet device used by a newly enabled bearer, so that the
addition or removal of a device does not cause problems.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/eth_media.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c index b69092eb95d8..69bedd8a297b 100644 --- a/net/tipc/eth_media.c +++ b/net/tipc/eth_media.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * net/tipc/eth_media.c: Ethernet bearer support for TIPC | 2 | * net/tipc/eth_media.c: Ethernet bearer support for TIPC |
3 | * | 3 | * |
4 | * Copyright (c) 2001-2007, Ericsson AB | 4 | * Copyright (c) 2001-2007, Ericsson AB |
5 | * Copyright (c) 2005-2007, Wind River Systems | 5 | * Copyright (c) 2005-2008, 2011, Wind River Systems |
6 | * All rights reserved. | 6 | * All rights reserved. |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without |
@@ -144,12 +144,15 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) | |||
144 | 144 | ||
145 | /* Find device with specified name */ | 145 | /* Find device with specified name */ |
146 | 146 | ||
147 | read_lock(&dev_base_lock); | ||
147 | for_each_netdev(&init_net, pdev) { | 148 | for_each_netdev(&init_net, pdev) { |
148 | if (!strncmp(pdev->name, driver_name, IFNAMSIZ)) { | 149 | if (!strncmp(pdev->name, driver_name, IFNAMSIZ)) { |
149 | dev = pdev; | 150 | dev = pdev; |
151 | dev_hold(dev); | ||
150 | break; | 152 | break; |
151 | } | 153 | } |
152 | } | 154 | } |
155 | read_unlock(&dev_base_lock); | ||
153 | if (!dev) | 156 | if (!dev) |
154 | return -ENODEV; | 157 | return -ENODEV; |
155 | 158 | ||
@@ -166,7 +169,6 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) | |||
166 | eb_ptr->tipc_packet_type.func = recv_msg; | 169 | eb_ptr->tipc_packet_type.func = recv_msg; |
167 | eb_ptr->tipc_packet_type.af_packet_priv = eb_ptr; | 170 | eb_ptr->tipc_packet_type.af_packet_priv = eb_ptr; |
168 | INIT_LIST_HEAD(&(eb_ptr->tipc_packet_type.list)); | 171 | INIT_LIST_HEAD(&(eb_ptr->tipc_packet_type.list)); |
169 | dev_hold(dev); | ||
170 | dev_add_pack(&eb_ptr->tipc_packet_type); | 172 | dev_add_pack(&eb_ptr->tipc_packet_type); |
171 | } | 173 | } |
172 | 174 | ||