netifd: fix a use-after-free issue on wireless config update
authorFelix Fietkau <nbd@openwrt.org>
Tue, 29 Apr 2014 13:16:21 +0000 (15:16 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 29 Apr 2014 13:16:22 +0000 (15:16 +0200)
After vlist_add() the device could have been freed

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
wireless.c

index ffb9e38c6666885fa1c558846c7f51d3f5138a1c..f3c95496864aa39532ca944078a13606c7ca875e 100644 (file)
@@ -629,7 +629,6 @@ wireless_device_create(struct wireless_driver *drv, const char *name, struct blo
        INIT_LIST_HEAD(&wdev->script_proc);
        vlist_init(&wdev->interfaces, avl_strcmp, vif_update);
        wdev->interfaces.keep_old = true;
-       vlist_add(&wireless_devices, &wdev->node, wdev->name);
 
        wdev->timeout.cb = wireless_device_setup_timeout;
        wdev->script_task.cb = wireless_device_script_task_cb;
@@ -640,6 +639,8 @@ wireless_device_create(struct wireless_driver *drv, const char *name, struct blo
        wdev->script_proc_fd.cb = wireless_proc_poll_fd;
 
        wdev->script_check.cb = wireless_device_check_script_tasks;
+
+       vlist_add(&wireless_devices, &wdev->node, wdev->name);
 }
 
 void wireless_interface_create(struct wireless_device *wdev, struct blob_attr *data, const char *section)