]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
batman-adv: don't access unregistered net_device object
authorAntonio Quartulli <antonio@meshcoding.com>
Tue, 4 Aug 2015 20:26:19 +0000 (22:26 +0200)
committerAntonio Quartulli <antonio@meshcoding.com>
Thu, 27 Aug 2015 18:15:33 +0000 (20:15 +0200)
In batadv_hardif_disable_interface() there is a call to
batadv_softif_destroy_sysfs() which in turns invokes
unregister_netdevice() on the soft_iface.
After this point we cannot rely on the soft_iface object
anymore because it might get free'd by the netdev periodic
routine at any time.

For this reason the netdev_upper_dev_unlink(.., soft_iface) call
is moved before the invocation of batadv_softif_destroy_sysfs() so
that we can be sure that the soft_iface object is still valid.

Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
net/batman-adv/hard-interface.c

index f4a15d2e5eaf89e0c429d6bb8afa2597a1fc21b9..0565b20bfa6dbcd663d64afa547be9591f81ff8c 100644 (file)
@@ -528,6 +528,8 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface,
        batadv_purge_outstanding_packets(bat_priv, hard_iface);
        dev_put(hard_iface->soft_iface);
 
+       netdev_upper_dev_unlink(hard_iface->net_dev, hard_iface->soft_iface);
+
        /* nobody uses this interface anymore */
        if (!bat_priv->num_ifaces) {
                batadv_gw_check_client_stop(bat_priv);
@@ -536,7 +538,6 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface,
                        batadv_softif_destroy_sysfs(hard_iface->soft_iface);
        }
 
-       netdev_upper_dev_unlink(hard_iface->net_dev, hard_iface->soft_iface);
        hard_iface->soft_iface = NULL;
        batadv_hardif_free_ref(hard_iface);