]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
better error reporting if dev/phy does not exist
authorJohannes Berg <johannes@sipsolutions.net>
Thu, 12 Mar 2009 10:13:36 +0000 (11:13 +0100)
committerJohannes Berg <johannes@sipsolutions.net>
Thu, 12 Mar 2009 10:13:36 +0000 (11:13 +0100)
iw.c

diff --git a/iw.c b/iw.c
index f1d912b9fd0d9798527a307e8822d243c6206f32..9194bbd802a8a08c1b83f170c48cca0c56f9ab6e 100644 (file)
--- a/iw.c
+++ b/iw.c
@@ -149,6 +149,8 @@ static int phy_lookup(char *name)
        snprintf(buf, sizeof(buf), "/sys/class/ieee80211/%s/index", name);
 
        fd = open(buf, O_RDONLY);
+       if (fd < 0)
+               return -1;
        pos = read(fd, buf, sizeof(buf) - 1);
        if (pos < 0)
                return -1;
@@ -200,6 +202,8 @@ static int handle_cmd(struct nl80211_state *state,
                break;
        case CIB_NETDEV:
                devidx = if_nametoindex(*argv);
+               if (devidx == 0)
+                       devidx = -1;
                argc--;
                argv++;
                break;
@@ -207,6 +211,9 @@ static int handle_cmd(struct nl80211_state *state,
                break;
        }
 
+       if (devidx < 0)
+               return -errno;
+
        section = command = *argv;
        argc--;
        argv++;