Commit 3f427604 authored by Marek Lindner's avatar Marek Lindner Committed by Greg Kroah-Hartman

Staging: batman-adv: use rcu callbacks when freeing batman_if

Signed-off-by: default avatarMarek Lindner <lindner_marek@yahoo.de>
Signed-off-by: default avatarSven Eckelmann <sven.eckelmann@gmx.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent b4abfcd4
...@@ -36,6 +36,15 @@ ...@@ -36,6 +36,15 @@
/* protect update critical side of if_list - but not the content */ /* protect update critical side of if_list - but not the content */
static DEFINE_SPINLOCK(if_list_lock); static DEFINE_SPINLOCK(if_list_lock);
static void hardif_free_rcu(struct rcu_head *rcu)
{
struct batman_if *batman_if;
batman_if = container_of(rcu, struct batman_if, rcu);
dev_put(batman_if->net_dev);
kref_put(&batman_if->refcount, hardif_free_ref);
}
struct batman_if *get_batman_if_by_netdev(struct net_device *net_dev) struct batman_if *get_batman_if_by_netdev(struct net_device *net_dev)
{ {
struct batman_if *batman_if; struct batman_if *batman_if;
...@@ -462,9 +471,8 @@ static void hardif_remove_interface(struct batman_if *batman_if) ...@@ -462,9 +471,8 @@ static void hardif_remove_interface(struct batman_if *batman_if)
return; return;
batman_if->if_status = IF_TO_BE_REMOVED; batman_if->if_status = IF_TO_BE_REMOVED;
synchronize_rcu();
sysfs_del_hardif(&batman_if->hardif_obj); sysfs_del_hardif(&batman_if->hardif_obj);
kref_put(&batman_if->refcount, hardif_free_ref); call_rcu(&batman_if->rcu, hardif_free_rcu);
} }
void hardif_remove_interfaces(void) void hardif_remove_interfaces(void)
......
...@@ -47,7 +47,6 @@ static inline void hardif_free_ref(struct kref *refcount) ...@@ -47,7 +47,6 @@ static inline void hardif_free_ref(struct kref *refcount)
struct batman_if *batman_if; struct batman_if *batman_if;
batman_if = container_of(refcount, struct batman_if, refcount); batman_if = container_of(refcount, struct batman_if, refcount);
dev_put(batman_if->net_dev);
kfree(batman_if); kfree(batman_if);
} }
......
...@@ -46,6 +46,7 @@ struct batman_if { ...@@ -46,6 +46,7 @@ struct batman_if {
struct kref refcount; struct kref refcount;
struct packet_type batman_adv_ptype; struct packet_type batman_adv_ptype;
struct net_device *soft_iface; struct net_device *soft_iface;
struct rcu_head rcu;
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment