aboutsummaryrefslogtreecommitdiffstats
path: root/net/caif/caif_dev.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2011-10-24 17:25:21 -0400
committerDavid S. Miller <davem@davemloft.net>2011-10-25 19:22:23 -0400
commit08613e4626c06ca408fc55071f6aedee36986a87 (patch)
tree4251c4fa37ed1571a61505a70fed4dffdaaece82 /net/caif/caif_dev.c
parent59fdaca9a4497ada47328d7b4b406b98a6f1c1a6 (diff)
caif: Fix BUG() with network namespaces
The caif code will register its own pernet_operations, and then register a netdevice_notifier. Each time the netdevice_notifier is triggered, it'll do some stuff... including a lookup of its own pernet stuff with net_generic(). If the net_generic() call ever returns NULL, the caif code will BUG(). That doesn't seem *so* unreasonable, I suppose — it does seem like it should never happen. However, it *does* happen. When we clone a network namespace, setup_net() runs through all the pernet_operations one at a time. It gets to loopback before it gets to caif. And loopback_net_init() registers a netdevice... while caif hasn't been initialised. So the caif netdevice notifier triggers, and immediately goes BUG(). We could imagine a complex and overengineered solution to this generic class of problems, but this patch takes the simple approach. It just makes caif_device_notify() *not* go looking for its pernet data structures if the device it's being notified about isn't a caif device in the first place. Cc: stable@kernel.org Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Acked-by: Sjur Brændeland <sjur.brandeland@stericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/caif/caif_dev.c')
-rw-r--r--net/caif/caif_dev.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c
index 7f9ac0742d19..47fc8f3a47cf 100644
--- a/net/caif/caif_dev.c
+++ b/net/caif/caif_dev.c
@@ -212,8 +212,7 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,
212 enum cfcnfg_phy_preference pref; 212 enum cfcnfg_phy_preference pref;
213 enum cfcnfg_phy_type phy_type; 213 enum cfcnfg_phy_type phy_type;
214 struct cfcnfg *cfg; 214 struct cfcnfg *cfg;
215 struct caif_device_entry_list *caifdevs = 215 struct caif_device_entry_list *caifdevs;
216 caif_device_list(dev_net(dev));
217 216
218 if (dev->type != ARPHRD_CAIF) 217 if (dev->type != ARPHRD_CAIF)
219 return 0; 218 return 0;
@@ -222,6 +221,8 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,
222 if (cfg == NULL) 221 if (cfg == NULL)
223 return 0; 222 return 0;
224 223
224 caifdevs = caif_device_list(dev_net(dev));
225
225 switch (what) { 226 switch (what) {
226 case NETDEV_REGISTER: 227 case NETDEV_REGISTER:
227 caifd = caif_device_alloc(dev); 228 caifd = caif_device_alloc(dev);