fix file descriptor leakages
authorGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Fri, 28 Sep 2012 16:07:10 +0000 (18:07 +0200)
committerGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Fri, 28 Sep 2012 16:07:10 +0000 (18:07 +0200)
lib/netdev-pltap.c
lib/tunalloc.c

index c9252e5..6c36e96 100644 (file)
@@ -467,6 +467,7 @@ get_etheraddr(const char *netdev_name, uint8_t ea[ETH_ADDR_LEN])
         VLOG(errno == ENODEV ? VLL_INFO : VLL_ERR,
              "ioctl(SIOCGIFHWADDR) on %s device failed: %s",
              netdev_name, strerror(errno));
         VLOG(errno == ENODEV ? VLL_INFO : VLL_ERR,
              "ioctl(SIOCGIFHWADDR) on %s device failed: %s",
              netdev_name, strerror(errno));
+       close(af_inet_sock);
         return errno;
     }
     hwaddr_family = ifr.ifr_hwaddr.sa_family;
         return errno;
     }
     hwaddr_family = ifr.ifr_hwaddr.sa_family;
@@ -475,6 +476,7 @@ get_etheraddr(const char *netdev_name, uint8_t ea[ETH_ADDR_LEN])
                   netdev_name, hwaddr_family);
     }
     memcpy(ea, ifr.ifr_hwaddr.sa_data, ETH_ADDR_LEN);
                   netdev_name, hwaddr_family);
     }
     memcpy(ea, ifr.ifr_hwaddr.sa_data, ETH_ADDR_LEN);
+    close(af_inet_sock);
     return 0;
 }
 
     return 0;
 }
 
index 1f083e5..4cb2f8e 100644 (file)
@@ -97,5 +97,8 @@ int tun_alloc(int iftype, char *if_name)
     }
 
     remotefd = receive_vif_fd(control_fd, if_name);
     }
 
     remotefd = receive_vif_fd(control_fd, if_name);
+
+    close(control_fd);
+
     return remotefd;
 }
     return remotefd;
 }