diff options
author | Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de> | 2013-01-11 04:19:51 -0500 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2013-01-19 08:18:12 -0500 |
commit | 5bc44dc8458cbac08c664f2f337326bf87cc924b (patch) | |
tree | 05828c0b6a6f00138a539c0ce39e3ea0b109dbce /net/batman-adv/hard-interface.c | |
parent | e76e4320a26ba6301dfd3e9a28a1e3faccd302ab (diff) |
batman-adv: postpone sysfs removal when unregistering
When processing the unregister notify for a hard interface, removing
the sysfs files may lead to a circular deadlock (rtnl mutex <->
s_active).
To overcome this problem, postpone the sysfs removal in a worker.
Reported-by: Sasha Levin <sasha.levin@oracle.com>
Reported-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'net/batman-adv/hard-interface.c')
-rw-r--r-- | net/batman-adv/hard-interface.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index f1d37cd81815..cb3191fe60fc 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c | |||
@@ -457,6 +457,24 @@ out: | |||
457 | batadv_hardif_free_ref(primary_if); | 457 | batadv_hardif_free_ref(primary_if); |
458 | } | 458 | } |
459 | 459 | ||
460 | /** | ||
461 | * batadv_hardif_remove_interface_finish - cleans up the remains of a hardif | ||
462 | * @work: work queue item | ||
463 | * | ||
464 | * Free the parts of the hard interface which can not be removed under | ||
465 | * rtnl lock (to prevent deadlock situations). | ||
466 | */ | ||
467 | static void batadv_hardif_remove_interface_finish(struct work_struct *work) | ||
468 | { | ||
469 | struct batadv_hard_iface *hard_iface; | ||
470 | |||
471 | hard_iface = container_of(work, struct batadv_hard_iface, | ||
472 | cleanup_work); | ||
473 | |||
474 | batadv_sysfs_del_hardif(&hard_iface->hardif_obj); | ||
475 | batadv_hardif_free_ref(hard_iface); | ||
476 | } | ||
477 | |||
460 | static struct batadv_hard_iface * | 478 | static struct batadv_hard_iface * |
461 | batadv_hardif_add_interface(struct net_device *net_dev) | 479 | batadv_hardif_add_interface(struct net_device *net_dev) |
462 | { | 480 | { |
@@ -484,6 +502,9 @@ batadv_hardif_add_interface(struct net_device *net_dev) | |||
484 | hard_iface->soft_iface = NULL; | 502 | hard_iface->soft_iface = NULL; |
485 | hard_iface->if_status = BATADV_IF_NOT_IN_USE; | 503 | hard_iface->if_status = BATADV_IF_NOT_IN_USE; |
486 | INIT_LIST_HEAD(&hard_iface->list); | 504 | INIT_LIST_HEAD(&hard_iface->list); |
505 | INIT_WORK(&hard_iface->cleanup_work, | ||
506 | batadv_hardif_remove_interface_finish); | ||
507 | |||
487 | /* extra reference for return */ | 508 | /* extra reference for return */ |
488 | atomic_set(&hard_iface->refcount, 2); | 509 | atomic_set(&hard_iface->refcount, 2); |
489 | 510 | ||
@@ -518,8 +539,7 @@ static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) | |||
518 | return; | 539 | return; |
519 | 540 | ||
520 | hard_iface->if_status = BATADV_IF_TO_BE_REMOVED; | 541 | hard_iface->if_status = BATADV_IF_TO_BE_REMOVED; |
521 | batadv_sysfs_del_hardif(&hard_iface->hardif_obj); | 542 | queue_work(batadv_event_workqueue, &hard_iface->cleanup_work); |
522 | batadv_hardif_free_ref(hard_iface); | ||
523 | } | 543 | } |
524 | 544 | ||
525 | void batadv_hardif_remove_interfaces(void) | 545 | void batadv_hardif_remove_interfaces(void) |