wireless: process and close script file descriptor when rerunning setup
authorFelix Fietkau <nbd@nbd.name>
Wed, 29 Sep 2021 12:03:55 +0000 (14:03 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 29 Sep 2021 13:07:16 +0000 (15:07 +0200)
On reloading, setup is called without a teardown, so the previous fd might
still be open. Clear it to avoid a leak.

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

index 9c49da0e2b99a407ac2a69b88a966770f22f6f04..dafd49aa693b18416ef371e0490ccda45e24d872 100644 (file)
@@ -431,6 +431,9 @@ wireless_device_run_handler(struct wireless_device *wdev, bool up)
        argv[i] = NULL;
 
        if (up && pipe(fds) == 0) {
+               if (wdev->script_proc_fd.fd >= 0)
+                       wireless_close_script_proc_fd(wdev);
+
                wdev->script_proc_fd.fd = fds[0];
                uloop_fd_add(&wdev->script_proc_fd,
                             ULOOP_READ | ULOOP_EDGE_TRIGGER);