nl80211: fix possible fd leak in nl80211_hostapd_hup()
[project/iwinfo.git] / iwinfo_nl80211.c
index a65ed1e..a08d580 100644 (file)
@@ -951,7 +951,7 @@ static void nl80211_hostapd_hup(const char *ifname)
        if (phy)
        {
                snprintf(buf, sizeof(buf), "/var/run/wifi-%s.pid", phy);
-               if ((fd = open(buf, O_RDONLY)) > 0)
+               if ((fd = open(buf, O_RDONLY)) >= 0)
                {
                        if (read(fd, buf, sizeof(buf)) > 0)
                                pid = atoi(buf);
@@ -2698,7 +2698,7 @@ static int nl80211_get_mbssid_support(const char *ifname, int *buf)
 
 static int nl80211_get_hardware_id(const char *ifname, char *buf)
 {
-       int rv;
+       int rv = -1;
        char *res;
 
        /* Got a radioX pseudo interface, find some interface on it or create one */