]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
fix fd leak in phy_lookup()
authorEric Sesterhenn <eric.sesterhenn@lsexperts.de>
Mon, 2 Nov 2009 09:46:38 +0000 (10:46 +0100)
committerJohannes Berg <johannes@sipsolutions.net>
Mon, 2 Nov 2009 09:46:38 +0000 (10:46 +0100)
iw.c

diff --git a/iw.c b/iw.c
index 8fcf2f61a2c560cccb5b6eaea70cf3d44d4d8e47..562f17b6b0900ddcef4898403828d74f5579a463 100644 (file)
--- a/iw.c
+++ b/iw.c
@@ -223,9 +223,12 @@ static int phy_lookup(char *name)
        if (fd < 0)
                return -1;
        pos = read(fd, buf, sizeof(buf) - 1);
-       if (pos < 0)
+       if (pos < 0) {
+               close(fd);
                return -1;
+       }
        buf[pos] = '\0';
+       close(fd);
        return atoi(buf);
 }