]> git.ipfire.org Git - thirdparty/iw.git/blobdiff - phy.c
iw: scan: parse wps version2
[thirdparty/iw.git] / phy.c
diff --git a/phy.c b/phy.c
index a4425ea7b1fa64dc43a8eb95663bfd21fe9534c7..716677eff28d4462fdb7d448f531b346fd9df389 100644 (file)
--- a/phy.c
+++ b/phy.c
@@ -1,6 +1,7 @@
 #include <stdbool.h>
 #include <errno.h>
 #include <strings.h>
+#include <unistd.h>
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -329,8 +330,9 @@ static int handle_cac(struct nl80211_state *state,
                err = parse_freqchan(&chandef, false, argc - 3, argv + 3, NULL);
        } else {
                err = 1;
-               goto err_out;
        }
+       if (err)
+               goto err_out;
 
        cac_trigger_argv = calloc(argc + 1, sizeof(char*));
        if (!cac_trigger_argv) {
@@ -531,7 +533,7 @@ static int handle_netns(struct nl80211_state *state,
                        enum id_input id)
 {
        char *end;
-       int fd;
+       int fd = -1;
 
        if (argc < 1 || !*argv[0])
                return 1;
@@ -559,6 +561,8 @@ static int handle_netns(struct nl80211_state *state,
        return 1;
 
  nla_put_failure:
+       if (fd >= 0)
+               close(fd);
        return -ENOBUFS;
 }
 COMMAND(set, netns, "{ <pid> | name <nsname> }",