From 3208581a15bc7d8a3e65b14a2a2c9fea77696bf9 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Fri, 13 Jan 2006 23:24:09 +0000 Subject: [PATCH] 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 --- sys/net/if_ef.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/net/if_ef.c b/sys/net/if_ef.c index 2c2828cba73b..04262c6fa9a6 100644 --- a/sys/net/if_ef.c +++ b/sys/net/if_ef.c @@ -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";