Merge if_ef.c:1.38 from HEAD to RELENG_6:

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

Approved by:	re (scottl)
This commit is contained in:
rwatson 2006-02-14 21:11:19 +00:00
parent bcc6ac0035
commit f6557302f2

View File

@ -477,8 +477,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";