X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/91447636331957f3d9b5ca5b508f07c526b0074d..0c530ab8987f0ae6a1a3d9284f40182b88852816:/bsd/net/kpi_interface.c diff --git a/bsd/net/kpi_interface.c b/bsd/net/kpi_interface.c index a5d64adac..74143ae02 100644 --- a/bsd/net/kpi_interface.c +++ b/bsd/net/kpi_interface.c @@ -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))