mac802154: Handle associating
[linux-2.6-block.git] / net / ieee802154 / core.c
index cd69bdbfd59f7f03102aa7a0c7555e43385371fc..a08d75dd56ad641ac7f8ee7e54ddd0ee12f21c1a 100644 (file)
@@ -198,6 +198,16 @@ void wpan_phy_free(struct wpan_phy *phy)
 }
 EXPORT_SYMBOL(wpan_phy_free);
 
+static void cfg802154_free_peer_structures(struct wpan_dev *wpan_dev)
+{
+       mutex_lock(&wpan_dev->association_lock);
+
+       kfree(wpan_dev->parent);
+       wpan_dev->parent = NULL;
+
+       mutex_unlock(&wpan_dev->association_lock);
+}
+
 int cfg802154_switch_netns(struct cfg802154_registered_device *rdev,
                           struct net *net)
 {
@@ -293,6 +303,8 @@ static int cfg802154_netdev_notifier_call(struct notifier_block *nb,
                rdev->opencount++;
                break;
        case NETDEV_UNREGISTER:
+               cfg802154_free_peer_structures(wpan_dev);
+
                /* It is possible to get NETDEV_UNREGISTER
                 * multiple times. To detect that, check
                 * that the interface is still on the list