in_getmulti: Fix recursion on if_addr_lock on malloc failure

When the M_NOWAIT allocation fails, we recurse the if_addr_lock trying
to clean up.  Reorder the cleanup after dropping the if_addr_lock.  The
obvious race is already possible between if_addmulti and IF_ADDR_WLOCK
above, so it must be ok.

Submitted by:	Ryan Libby <rlibby@gmail.com>
Reviewed by:	jhb
Found with:	M_NOWAIT failure injection testing
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D4138
This commit is contained in:
Conrad Meyer 2015-11-18 23:53:13 +00:00
parent dc5c5b1da8
commit 3fbd30d495
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=291040

View File

@ -515,8 +515,8 @@ in_getmulti(struct ifnet *ifp, const struct in_addr *group,
*/
inm = malloc(sizeof(*inm), M_IPMADDR, M_NOWAIT | M_ZERO);
if (inm == NULL) {
if_delmulti_ifma(ifma);
IF_ADDR_WUNLOCK(ifp);
if_delmulti_ifma(ifma);
return (ENOMEM);
}
inm->inm_addr = *group;