]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/net/kpi_interface.c
xnu-792.25.20.tar.gz
[apple/xnu.git] / bsd / net / kpi_interface.c
index a5d64adac64988f6c510fa441fbc322637970c35..74143ae02c104cde12a701031b4547a20932e756 100644 (file)
@@ -1024,7 +1024,10 @@ errno_t ifnet_get_multicast_list(ifnet_t interface, ifmultiaddr_t **addresses)
        }
        
        MALLOC(*addresses, ifmultiaddr_t*, sizeof(ifmultiaddr_t) * (cmax + 1), M_TEMP, M_NOWAIT);
-       if (*addresses == NULL) return ENOMEM;
+       if (*addresses == NULL) {
+               if (lock) ifnet_lock_done(interface);
+               return ENOMEM;
+       }
        
        LIST_FOREACH(addr, &interface->if_multiaddrs, ifma_link)
        {
@@ -1073,8 +1076,14 @@ ifnet_find_by_name(
        ifnet_head_lock_shared();
        TAILQ_FOREACH(ifp, &ifnet, if_link)
        {
-               struct sockaddr_dl *ll_addr =
-                       (struct sockaddr_dl *)ifnet_addrs[ifp->if_index - 1]->ifa_addr;
+               struct ifaddr *ifa = ifnet_addrs[ifp->if_index - 1];
+               struct sockaddr_dl *ll_addr;
+               
+               if (!ifa || !ifa->ifa_addr)
+                       continue;
+               
+               ll_addr = (struct sockaddr_dl *)ifa->ifa_addr;
+               
                if ((ifp->if_eflags & IFEF_DETACHING) == 0 &&
                        namelen == ll_addr->sdl_nlen &&
                        (strncmp(ll_addr->sdl_data, ifname, ll_addr->sdl_nlen) == 0))