diff options
-rw-r--r-- | net/phonet/pn_dev.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c index d87388c94b00..bc4a33bf2d3d 100644 --- a/net/phonet/pn_dev.c +++ b/net/phonet/pn_dev.c | |||
@@ -313,19 +313,14 @@ static struct notifier_block phonet_device_notifier = { | |||
313 | /* Per-namespace Phonet devices handling */ | 313 | /* Per-namespace Phonet devices handling */ |
314 | static int phonet_init_net(struct net *net) | 314 | static int phonet_init_net(struct net *net) |
315 | { | 315 | { |
316 | struct phonet_net *pnn = kzalloc(sizeof(*pnn), GFP_KERNEL); | 316 | struct phonet_net *pnn = net_generic(net, phonet_net_id); |
317 | if (!pnn) | ||
318 | return -ENOMEM; | ||
319 | 317 | ||
320 | if (!proc_net_fops_create(net, "phonet", 0, &pn_sock_seq_fops)) { | 318 | if (!proc_net_fops_create(net, "phonet", 0, &pn_sock_seq_fops)) |
321 | kfree(pnn); | ||
322 | return -ENOMEM; | 319 | return -ENOMEM; |
323 | } | ||
324 | 320 | ||
325 | INIT_LIST_HEAD(&pnn->pndevs.list); | 321 | INIT_LIST_HEAD(&pnn->pndevs.list); |
326 | mutex_init(&pnn->pndevs.lock); | 322 | mutex_init(&pnn->pndevs.lock); |
327 | mutex_init(&pnn->routes.lock); | 323 | mutex_init(&pnn->routes.lock); |
328 | net_assign_generic(net, phonet_net_id, pnn); | ||
329 | return 0; | 324 | return 0; |
330 | } | 325 | } |
331 | 326 | ||
@@ -349,18 +344,19 @@ static void phonet_exit_net(struct net *net) | |||
349 | rtnl_unlock(); | 344 | rtnl_unlock(); |
350 | 345 | ||
351 | proc_net_remove(net, "phonet"); | 346 | proc_net_remove(net, "phonet"); |
352 | kfree(pnn); | ||
353 | } | 347 | } |
354 | 348 | ||
355 | static struct pernet_operations phonet_net_ops = { | 349 | static struct pernet_operations phonet_net_ops = { |
356 | .init = phonet_init_net, | 350 | .init = phonet_init_net, |
357 | .exit = phonet_exit_net, | 351 | .exit = phonet_exit_net, |
352 | .id = &phonet_net_id, | ||
353 | .size = sizeof(struct phonet_net), | ||
358 | }; | 354 | }; |
359 | 355 | ||
360 | /* Initialize Phonet devices list */ | 356 | /* Initialize Phonet devices list */ |
361 | int __init phonet_device_init(void) | 357 | int __init phonet_device_init(void) |
362 | { | 358 | { |
363 | int err = register_pernet_gen_device(&phonet_net_id, &phonet_net_ops); | 359 | int err = register_pernet_device(&phonet_net_ops); |
364 | if (err) | 360 | if (err) |
365 | return err; | 361 | return err; |
366 | 362 | ||
@@ -375,7 +371,7 @@ void phonet_device_exit(void) | |||
375 | { | 371 | { |
376 | rtnl_unregister_all(PF_PHONET); | 372 | rtnl_unregister_all(PF_PHONET); |
377 | unregister_netdevice_notifier(&phonet_device_notifier); | 373 | unregister_netdevice_notifier(&phonet_device_notifier); |
378 | unregister_pernet_gen_device(phonet_net_id, &phonet_net_ops); | 374 | unregister_pernet_device(&phonet_net_ops); |
379 | } | 375 | } |
380 | 376 | ||
381 | int phonet_route_add(struct net_device *dev, u8 daddr) | 377 | int phonet_route_add(struct net_device *dev, u8 daddr) |