Check the right ifnet pointer to see if if_alloc() failed or not in

ef_clone(); we were testing the original ifnet, not the one allocated.

When aborting ef_clone() due to if_alloc() failing, free the allocated
efnet structure rather than leaking it.

Noticed by:	Coverity Prevent analysis tool
MFC after:	3 days
This commit is contained in:
Robert Watson 2006-01-13 23:24:09 +00:00
parent ae7c484e82
commit 3208581a15

View File

@ -473,8 +473,10 @@ ef_clone(struct ef_link *efl, int ft)
efp->ef_pifp = ifp;
efp->ef_frametype = ft;
eifp = efp->ef_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL)
if (eifp == NULL) {
free(efp, M_IFADDR);
return (ENOSPC);
}
snprintf(eifp->if_xname, IFNAMSIZ,
"%sf%d", ifp->if_xname, efp->ef_frametype);
eifp->if_dname = "ef";