75da6fbc90cf6c5d63efb5cdcd1a80eec81d295a
[feed/routing.git] / batman-adv / patches / 0001-batman-adv-don-t-access-unregistered-net_device-obje.patch
1 From 958aafba93c7e408237298c5b2c5d7c3e318402c Mon Sep 17 00:00:00 2001
2 From: Antonio Quartulli <antonio@meshcoding.com>
3 Date: Tue, 4 Aug 2015 22:26:19 +0200
4 Subject: [PATCH 1/9] batman-adv: don't access unregistered net_device object
5
6 In batadv_hardif_disable_interface() there is a call to
7 batadv_softif_destroy_sysfs() which in turns invokes
8 unregister_netdevice() on the soft_iface.
9 After this point we cannot rely on the soft_iface object
10 anymore because it might get free'd by the netdev periodic
11 routine at any time.
12
13 For this reason the netdev_upper_dev_unlink(.., soft_iface) call
14 is moved before the invocation of batadv_softif_destroy_sysfs() so
15 that we can be sure that the soft_iface object is still valid.
16
17 Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
18 Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
19 ---
20 net/batman-adv/hard-interface.c | 3 ++-
21 1 file changed, 2 insertions(+), 1 deletion(-)
22
23 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
24 index f4a15d2..0565b20 100644
25 --- a/net/batman-adv/hard-interface.c
26 +++ b/net/batman-adv/hard-interface.c
27 @@ -528,6 +528,8 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface,
28 batadv_purge_outstanding_packets(bat_priv, hard_iface);
29 dev_put(hard_iface->soft_iface);
30
31 + netdev_upper_dev_unlink(hard_iface->net_dev, hard_iface->soft_iface);
32 +
33 /* nobody uses this interface anymore */
34 if (!bat_priv->num_ifaces) {
35 batadv_gw_check_client_stop(bat_priv);
36 @@ -536,7 +538,6 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface,
37 batadv_softif_destroy_sysfs(hard_iface->soft_iface);
38 }
39
40 - netdev_upper_dev_unlink(hard_iface->net_dev, hard_iface->soft_iface);
41 hard_iface->soft_iface = NULL;
42 batadv_hardif_free_ref(hard_iface);
43
44 --
45 2.5.0
46